1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-10 21:33:27 +00:00

PS-1161 Added isLoading bool to verify if load() is still running. Keeping Loaded for the ngIf verification (#3198)

This commit is contained in:
aj-rosado
2022-08-04 12:09:32 +01:00
committed by GitHub
parent 83c0456340
commit 1e1a0b1481

View File

@@ -38,6 +38,7 @@ export class CurrentTabComponent implements OnInit, OnDestroy {
inSidebar = false; inSidebar = false;
searchTypeSearch = false; searchTypeSearch = false;
loaded = false; loaded = false;
isLoading = false;
showOrganizations = false; showOrganizations = false;
private totpCode: string; private totpCode: string;
@@ -71,7 +72,7 @@ export class CurrentTabComponent implements OnInit, OnDestroy {
this.ngZone.run(async () => { this.ngZone.run(async () => {
switch (message.command) { switch (message.command) {
case "syncCompleted": case "syncCompleted":
if (this.loaded) { if (this.isLoading) {
window.setTimeout(() => { window.setTimeout(() => {
this.load(); this.load();
}, 500); }, 500);
@@ -98,7 +99,7 @@ export class CurrentTabComponent implements OnInit, OnDestroy {
await this.load(); await this.load();
} else { } else {
this.loadedTimeout = window.setTimeout(async () => { this.loadedTimeout = window.setTimeout(async () => {
if (!this.loaded) { if (!this.isLoading) {
await this.load(); await this.load();
} }
}, 5000); }, 5000);
@@ -197,13 +198,13 @@ export class CurrentTabComponent implements OnInit, OnDestroy {
} }
private async load() { private async load() {
this.loaded = false; this.isLoading = false;
this.tab = await BrowserApi.getTabFromCurrentWindow(); this.tab = await BrowserApi.getTabFromCurrentWindow();
if (this.tab != null) { if (this.tab != null) {
this.url = this.tab.url; this.url = this.tab.url;
} else { } else {
this.loginCiphers = []; this.loginCiphers = [];
this.loaded = true; this.isLoading = this.loaded = true;
return; return;
} }
@@ -256,6 +257,6 @@ export class CurrentTabComponent implements OnInit, OnDestroy {
this.loginCiphers = this.loginCiphers.sort((a, b) => this.loginCiphers = this.loginCiphers.sort((a, b) =>
this.cipherService.sortCiphersByLastUsedThenName(a, b) this.cipherService.sortCiphersByLastUsedThenName(a, b)
); );
this.loaded = true; this.isLoading = this.loaded = true;
} }
} }