From 1e1a0b148173f2d0dc5acee9b901cd18966381e1 Mon Sep 17 00:00:00 2001 From: aj-rosado <109146700+aj-rosado@users.noreply.github.com> Date: Thu, 4 Aug 2022 12:09:32 +0100 Subject: [PATCH] PS-1161 Added isLoading bool to verify if load() is still running. Keeping Loaded for the ngIf verification (#3198) --- apps/browser/src/popup/vault/current-tab.component.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/apps/browser/src/popup/vault/current-tab.component.ts b/apps/browser/src/popup/vault/current-tab.component.ts index b196f9180d..7d5cf00466 100644 --- a/apps/browser/src/popup/vault/current-tab.component.ts +++ b/apps/browser/src/popup/vault/current-tab.component.ts @@ -38,6 +38,7 @@ export class CurrentTabComponent implements OnInit, OnDestroy { inSidebar = false; searchTypeSearch = false; loaded = false; + isLoading = false; showOrganizations = false; private totpCode: string; @@ -71,7 +72,7 @@ export class CurrentTabComponent implements OnInit, OnDestroy { this.ngZone.run(async () => { switch (message.command) { case "syncCompleted": - if (this.loaded) { + if (this.isLoading) { window.setTimeout(() => { this.load(); }, 500); @@ -98,7 +99,7 @@ export class CurrentTabComponent implements OnInit, OnDestroy { await this.load(); } else { this.loadedTimeout = window.setTimeout(async () => { - if (!this.loaded) { + if (!this.isLoading) { await this.load(); } }, 5000); @@ -197,13 +198,13 @@ export class CurrentTabComponent implements OnInit, OnDestroy { } private async load() { - this.loaded = false; + this.isLoading = false; this.tab = await BrowserApi.getTabFromCurrentWindow(); if (this.tab != null) { this.url = this.tab.url; } else { this.loginCiphers = []; - this.loaded = true; + this.isLoading = this.loaded = true; return; } @@ -256,6 +257,6 @@ export class CurrentTabComponent implements OnInit, OnDestroy { this.loginCiphers = this.loginCiphers.sort((a, b) => this.cipherService.sortCiphersByLastUsedThenName(a, b) ); - this.loaded = true; + this.isLoading = this.loaded = true; } }