Consider offline during update checks

Hides the spinner if the update checks fail cause the server is
unreachable

use new cleansup the code a little
This commit is contained in:
Sean Engelhardt 2019-12-02 16:55:46 +01:00
parent 876dd1f7d6
commit a6891ef8e1
11 changed files with 47 additions and 12 deletions

View File

@ -96,7 +96,7 @@
"karma-jasmine-html-reporter": "^1.4.0",
"npm-license-crawler": "^0.2.1",
"npm-run-all": "^4.1.5",
"prettier": "^1.18.2",
"prettier": "^1.19.1",
"protractor": "^5.4.2",
"resize-observer-polyfill": "^1.5.1",
"source-map-explorer": "^2.0.1",

View File

@ -625,7 +625,7 @@ export class LinenumberingService {
};
}
}
if (lineBreakAt !== null && (node.nodeValue[i] !== ' ' && node.nodeValue[i] !== '\n')) {
if (lineBreakAt !== null && node.nodeValue[i] !== ' ' && node.nodeValue[i] !== '\n') {
if (lineBreakAt.node === node) {
// The last possible breaking point is in this text node
const currLine = node.nodeValue.substring(currLineStart, lineBreakAt.offset + 1);

View File

@ -2,10 +2,12 @@ import { Injectable } from '@angular/core';
import { MatDialog, MatDialogRef } from '@angular/material';
import { Observable, Subject } from 'rxjs';
import { distinctUntilChanged } from 'rxjs/operators';
import { largeDialogSettings } from 'app/shared/utils/dialog-settings';
import { SuperSearchComponent } from 'app/site/common/components/super-search/super-search.component';
import { DataStoreUpgradeService } from '../core-services/data-store-upgrade.service';
import { OfflineService } from '../core-services/offline.service';
import { OpenSlidesService } from '../core-services/openslides.service';
import { OperatorService } from '../core-services/operator.service';
@ -43,6 +45,11 @@ export class OverlayService {
*/
private hasBooted = false;
/**
* Flag, whether the client is offline or not
*/
private isOffline = false;
/**
*
* @param dialogService Injects the `MatDialog` to show the `super-search.component`
@ -51,7 +58,8 @@ export class OverlayService {
private dialogService: MatDialog,
private operator: OperatorService,
OpenSlides: OpenSlidesService,
upgradeService: DataStoreUpgradeService
upgradeService: DataStoreUpgradeService,
offlineService: OfflineService
) {
// Subscribe to the current user.
operator.getViewUserObservable().subscribe(user => {
@ -70,6 +78,14 @@ export class OverlayService {
this.upgradeChecked = upgradeDone;
this.checkConnection();
});
// Subscribe to check if we are offline
offlineService
.isOffline()
.pipe(distinctUntilChanged())
.subscribe(offline => {
this.isOffline = offline;
this.checkConnection();
});
}
/**
@ -126,7 +142,7 @@ export class OverlayService {
* @returns True, if the three booleans are all true.
*/
public isConnectionStable(): boolean {
return this.upgradeChecked && this.hasBooted && (!!this.user || this.operator.isAnonymous);
return (this.upgradeChecked || this.isOffline) && this.hasBooted && (!!this.user || this.operator.isAnonymous);
}
/**

View File

@ -100,7 +100,10 @@ export abstract class PollService {
* TODO: Should be given by the server, and editable. For now they are hard
* coded
*/
private _specialPollVotes: [number, string][] = [[-1, 'majority'], [-2, 'undocumented']];
private _specialPollVotes: [number, string][] = [
[-1, 'majority'],
[-2, 'undocumented']
];
/**
* getter for the special vote values

View File

@ -209,7 +209,7 @@ export class SearchService {
.map(searchModel => {
const results = this.viewModelStore
.getAll(searchModel.collectionString)
.map(x => x as (BaseViewModel & Searchable))
.map(x => x as BaseViewModel & Searchable)
.filter(model =>
!searchOnlyById
? model.id === dedicatedId ||

View File

@ -69,7 +69,10 @@ export class SortingTreeComponent<T extends Identifiable & Displayable> implemen
/**
* The tree control
*/
public treeControl = new FlatTreeControl<FlatNode<T>>(node => node.level, node => node.expandable);
public treeControl = new FlatTreeControl<FlatNode<T>>(
node => node.level,
node => node.expandable
);
/**
* Source for the tree

View File

@ -312,7 +312,10 @@ export class ListOfSpeakersComponent extends BaseViewComponent implements OnInit
if (this.isSortMode) {
this.isSortMode = false;
this.listOfSpeakersRepo
.sortSpeakers(this.viewListOfSpeakers, this.listElement.sortedItems.map(el => el.id))
.sortSpeakers(
this.viewListOfSpeakers,
this.listElement.sortedItems.map(el => el.id)
)
.catch(this.raiseError);
}
}

View File

@ -494,7 +494,10 @@ export class AssignmentDetailComponent extends BaseViewComponent implements OnIn
*/
public onSortingChange(listInNewOrder: ViewAssignmentRelatedUser[]): void {
this.repo
.sortCandidates(listInNewOrder.map(relatedUser => relatedUser.id), this.assignment)
.sortCandidates(
listInNewOrder.map(relatedUser => relatedUser.id),
this.assignment
)
.catch(this.raiseError);
}

View File

@ -72,7 +72,10 @@ export class ViewCategory extends BaseViewModel<Category> implements CategoryTit
public formatForSearch(): SearchRepresentation {
return {
properties: [{ key: 'Name', value: this.name }, { key: 'Prefix', value: this.prefix }],
properties: [
{ key: 'Name', value: this.name },
{ key: 'Prefix', value: this.prefix }
],
searchValue: [this.name, this.prefix]
};
}

View File

@ -100,7 +100,8 @@ export class MotionCsvExportService {
const properties = sortMotionPropertyList(['identifier', 'title'].concat(contentToExport));
const exportProperties: (
| CsvColumnDefinitionProperty<ViewMotion>
| CsvColumnDefinitionMap<ViewMotion>)[] = properties.map(option => {
| CsvColumnDefinitionMap<ViewMotion>
)[] = properties.map(option => {
if (option === 'recommendation') {
return {
label: 'recommendation',

View File

@ -24,7 +24,10 @@ export class ViewTopic extends BaseViewModelWithAgendaItemAndListOfSpeakers<Topi
*/
public formatForSearch(): SearchRepresentation {
return {
properties: [{ key: 'Title', value: this.getTitle() }, { key: 'Text', value: this.text }],
properties: [
{ key: 'Title', value: this.getTitle() },
{ key: 'Text', value: this.text }
],
searchValue: [this.getTitle(), this.text]
};
}