Browse Source

Prevent version update dialog from showing twice

The problem with this is that launching the dialog a second time will
close the first dialog, therefore triggering a page reload.
Danilo Bargen 8 năm trước cách đây
mục cha
commit
11aaea3e60
1 tập tin đã thay đổi với 6 bổ sung0 xóa
  1. 6 0
      src/services/version.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();
         }, () => {