Skip to content

Commit b847d7d

Browse files
authored
Dismiss entitlements badge on cancel (microsoft#210807)
1 parent 5ffadee commit b847d7d

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/vs/workbench/contrib/accountEntitlements/browser/accountsEntitlements.contribution.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ class EntitlementsContribution extends Disposable implements IWorkbenchContribut
7979

8080
private registerListeners() {
8181

82+
if (this.storageService.getBoolean(accountsBadgeConfigKey, StorageScope.APPLICATION) === false) {
83+
// we have already shown the entitlements. Do not show again
84+
return;
85+
}
86+
8287
this._register(this.extensionService.onDidChangeExtensions(async (result) => {
8388
for (const ext of result.added) {
8489
if (ExtensionIdentifier.equals(this.productService.gitHubEntitlement!.extensionId, ext.identifier)) {
@@ -178,7 +183,15 @@ class EntitlementsContribution extends Disposable implements IWorkbenchContribut
178183
const menuTitle = org ? this.productService.gitHubEntitlement!.command.title.replace('{{org}}', org) : this.productService.gitHubEntitlement!.command.titleWithoutPlaceHolder;
179184

180185
const badge = new NumberBadge(1, () => menuTitle);
181-
this.accountsMenuBadgeDisposable.value = this.activityService.showAccountsActivity({ badge, });
186+
this.accountsMenuBadgeDisposable.value = this.activityService.showAccountsActivity({ badge });
187+
188+
this.contextService.onDidChangeContext(e => {
189+
if (e.affectsSome(new Set([accountsBadgeConfigKey]))) {
190+
if (!this.contextService.getContextKeyValue<boolean>(accountsBadgeConfigKey)) {
191+
this.accountsMenuBadgeDisposable.clear();
192+
}
193+
}
194+
});
182195

183196
this._register(registerAction2(class extends Action2 {
184197
constructor() {
@@ -221,7 +234,7 @@ class EntitlementsContribution extends Disposable implements IWorkbenchContribut
221234
});
222235
}
223236

224-
const contextKey = new RawContextKey<boolean>(accountsBadgeConfigKey, true).bindTo(contextKeyService);
237+
const contextKey = new RawContextKey<boolean>(accountsBadgeConfigKey, false).bindTo(contextKeyService);
225238
contextKey.set(false);
226239
storageService.store(accountsBadgeConfigKey, false, StorageScope.APPLICATION, StorageTarget.MACHINE);
227240
}

0 commit comments

Comments
 (0)