Explorar o código

Merge pull request #228 from threema-ch/version-edgecase

Improvements for version detection edge cases
Danilo Bargen %!s(int64=8) %!d(string=hai) anos
pai
achega
974c009eae
Modificáronse 2 ficheiros con 9 adicións e 1 borrados
  1. 6 0
      src/services/version.ts
  2. 3 1
      src/services/webclient.ts

+ 6 - 0
src/services/version.ts

@@ -27,6 +27,7 @@ export class VersionService {
     private $window: ng.IWindowService;
 
     private version: string;
+    private dialogShowing = false;
 
     constructor($log: ng.ILogService,
                 $http: ng.IHttpService,
@@ -114,10 +115,15 @@ export class VersionService {
      * A new version is available!
      */
     private notifyNewVersion(version: string): void {
+        if (this.dialogShowing === true) {
+            // Don't show again if dialog is already showing.
+            return;
+        }
         const confirm = this.$mdDialog.alert()
             .title(this.$translate.instant('version.NEW_VERSION', {version: version}))
             .textContent(this.$translate.instant('version.NEW_VERSION_BODY', {version: version}))
             .ok(this.$translate.instant('common.OK'));
+        this.dialogShowing = true;
         this.$mdDialog.show(confirm).then(() => {
             this.$window.location.reload();
         }, () => {

+ 3 - 1
src/services/webclient.ts

@@ -451,7 +451,9 @@ export class WebClientService {
                     this._requestInitialData();
 
                     // Fetch current version
-                    this.versionService.checkForUpdate();
+                    // Delay it to prevent the dialog from being closed by the messenger constructor,
+                    // which closes all open dialogs.
+                    this.$timeout(() => this.versionService.checkForUpdate(), 7000);
 
                     // Notify state service about data loading
                     this.stateService.updateConnectionBuildupState('loading');