浏览代码

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 年之前
父节点
当前提交
11aaea3e60
共有 1 个文件被更改,包括 6 次插入0 次删除
  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();
         }, () => {