From 57f4fa7be25d32556da285f06bfa24bfa6b041c0 Mon Sep 17 00:00:00 2001 From: alexyaang <59073590+alexyaang@users.noreply.github.com> Date: Mon, 11 Sep 2023 13:33:42 -0400 Subject: [PATCH 1/2] added fire soon --- .../registries/Azure/AzureRegistryDataProvider.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/tree/registries/Azure/AzureRegistryDataProvider.ts b/src/tree/registries/Azure/AzureRegistryDataProvider.ts index fd5036e74c..384d875603 100644 --- a/src/tree/registries/Azure/AzureRegistryDataProvider.ts +++ b/src/tree/registries/Azure/AzureRegistryDataProvider.ts @@ -62,7 +62,7 @@ export class AzureRegistryDataProvider extends RegistryV2DataProvider implements if (isRegistryRoot(element)) { if (!await this.subscriptionProvider.isSignedIn()) { await this.subscriptionProvider.signIn(); - this.onDidChangeTreeDataEmitter.fire(element); // TODO: this fires too fast, need a "fire soon" analogue + void this.fireSoon(element); return []; } @@ -215,4 +215,14 @@ export class AzureRegistryDataProvider extends RegistryV2DataProvider implements // eslint-disable-next-line @typescript-eslint/no-non-null-assertion return this.authenticationProviders.get(registryString)!; } + + private async fireSoon(element?: CommonRegistryItem | undefined): Promise { + return new Promise(resolve => { + setTimeout(() => { + this.onDidChangeTreeDataEmitter.fire(element); + resolve(); + }, 5); + }); + } + } From a87eb7c7fafc231580f3b3e44ae34914d2800473 Mon Sep 17 00:00:00 2001 From: alexyaang <59073590+alexyaang@users.noreply.github.com> Date: Mon, 11 Sep 2023 14:00:19 -0400 Subject: [PATCH 2/2] clear time out --- .../registries/Azure/AzureRegistryDataProvider.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/tree/registries/Azure/AzureRegistryDataProvider.ts b/src/tree/registries/Azure/AzureRegistryDataProvider.ts index 384d875603..118447487b 100644 --- a/src/tree/registries/Azure/AzureRegistryDataProvider.ts +++ b/src/tree/registries/Azure/AzureRegistryDataProvider.ts @@ -62,7 +62,7 @@ export class AzureRegistryDataProvider extends RegistryV2DataProvider implements if (isRegistryRoot(element)) { if (!await this.subscriptionProvider.isSignedIn()) { await this.subscriptionProvider.signIn(); - void this.fireSoon(element); + this.fireSoon(element); return []; } @@ -216,13 +216,11 @@ export class AzureRegistryDataProvider extends RegistryV2DataProvider implements return this.authenticationProviders.get(registryString)!; } - private async fireSoon(element?: CommonRegistryItem | undefined): Promise { - return new Promise(resolve => { - setTimeout(() => { - this.onDidChangeTreeDataEmitter.fire(element); - resolve(); - }, 5); - }); + private fireSoon(element?: CommonRegistryItem | undefined) { + const timeout = setTimeout(() => { + clearTimeout(timeout); + this.onDidChangeTreeDataEmitter.fire(element); + }, 5); } }