From 00b2c47aae001c011b7db5b0dc96f8a70ce3cc15 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 13 Jan 2018 22:30:38 -0500 Subject: [PATCH] timeout for digest on sync and cipher view --- src/popup/app/settings/sync.component.ts | 20 +++---- .../app/vault/vaultViewCipherController.js | 54 ++++++++++--------- 2 files changed, 39 insertions(+), 35 deletions(-) diff --git a/src/popup/app/settings/sync.component.ts b/src/popup/app/settings/sync.component.ts index 1150833aae..2cf2ba07e8 100644 --- a/src/popup/app/settings/sync.component.ts +++ b/src/popup/app/settings/sync.component.ts @@ -8,7 +8,7 @@ export class SyncController { loading = false; constructor(private syncService: SyncService, private toastr: any, private $analytics: any, - private i18nService: any) { + private i18nService: any, private $timeout: ng.ITimeoutService) { this.i18n = i18nService; this.setLastSync(); } @@ -20,20 +20,22 @@ export class SyncController { if (success) { this.setLastSync(); this.$analytics.eventTrack('Synced Full'); - this.toastr.success(this.i18nService.syncingComplete); + this.toastr.success(this.i18n.syncingComplete); } else { - this.toastr.error(this.i18nService.syncingFailed); + this.toastr.error(this.i18n.syncingFailed); } }); } setLastSync() { - this.syncService.getLastSync().then((lastSync: any) => { - if (lastSync) { - this.lastSync = lastSync.toLocaleDateString() + ' ' + lastSync.toLocaleTimeString(); - } else { - this.lastSync = this.i18nService.never; - } + this.syncService.getLastSync().then((last: Date) => { + this.$timeout(() => { + if (last) { + this.lastSync = last.toLocaleDateString() + ' ' + last.toLocaleTimeString(); + } else { + this.lastSync = this.i18n.never; + } + }); }); } } diff --git a/src/popup/app/vault/vaultViewCipherController.js b/src/popup/app/vault/vaultViewCipherController.js index 8946996097..145cff2062 100644 --- a/src/popup/app/vault/vaultViewCipherController.js +++ b/src/popup/app/vault/vaultViewCipherController.js @@ -21,40 +21,42 @@ angular cipherObj = cipher; return cipher.decrypt(); }).then(function (model) { - $scope.cipher = model; + $timeout(function() { + $scope.cipher = model; - if (model.type == constantsService.cipherType.login && model.login) { - if (model.login.password) { - $scope.cipher.maskedPassword = $scope.maskValue(model.login.password); - } + if (model.type == constantsService.cipherType.login && model.login) { + if (model.login.password) { + $scope.cipher.maskedPassword = $scope.maskValue(model.login.password); + } - if (model.login.uri) { - $scope.cipher.showLaunch = model.login.uri.startsWith('http://') || model.login.uri.startsWith('https://'); - var domain = platformUtilsService.getDomain(model.login.uri); - if (domain) { - $scope.cipher.login.website = domain; + if (model.login.uri) { + $scope.cipher.showLaunch = model.login.uri.startsWith('http://') || model.login.uri.startsWith('https://'); + var domain = platformUtilsService.getDomain(model.login.uri); + if (domain) { + $scope.cipher.login.website = domain; + } + else { + $scope.cipher.login.website = model.login.uri; + } } else { - $scope.cipher.login.website = model.login.uri; + $scope.cipher.showLaunch = false; } } - else { - $scope.cipher.showLaunch = false; - } - } - if (model.login && model.login.totp && (cipherObj.organizationUseTotp || tokenService.getPremium())) { - totpUpdateCode(); - totpTick(); - - if (totpInterval) { - clearInterval(totpInterval); - } - - totpInterval = setInterval(function () { + if (model.login && model.login.totp && (cipherObj.organizationUseTotp || tokenService.getPremium())) { + totpUpdateCode(); totpTick(); - }, 1000); - } + + if (totpInterval) { + clearInterval(totpInterval); + } + + totpInterval = setInterval(function () { + totpTick(); + }, 1000); + } + }); }); $scope.edit = function (cipher) {