Skip to content

Commit 9bd5284

Browse files
committed
Updates organization permissions on manual sync
(#4300, #4398)
1 parent f1c5202 commit 9bd5284

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/plus/gk/organizationService.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export class OrganizationService implements Disposable {
3434
const orgId = await this.getActiveOrganizationId();
3535
void this.updateOrganizationPermissions(orgId);
3636
}),
37+
container.subscription.onDidCheckIn(this.onUserCheckedIn, this),
3738
container.subscription.onDidChange(this.onSubscriptionChanged, this),
3839
);
3940
}
@@ -128,6 +129,13 @@ export class OrganizationService implements Disposable {
128129
});
129130
}
130131

132+
private async onUserCheckedIn(): Promise<void> {
133+
const orgId = await this.getActiveOrganizationId();
134+
if (orgId == null) return;
135+
136+
await this.updateOrganizationPermissions(orgId, { force: true });
137+
}
138+
131139
private async onSubscriptionChanged(e: SubscriptionChangeEvent): Promise<void> {
132140
if (e.current?.account?.id == null) {
133141
this.updateOrganizations(undefined);
@@ -142,8 +150,11 @@ export class OrganizationService implements Disposable {
142150
void setContext('gitlens:gk:hasOrganizations', (organizations ?? []).length > 1);
143151
}
144152

145-
private async updateOrganizationPermissions(orgId: string | undefined): Promise<void> {
146-
const settings = orgId != null ? await this.getOrganizationSettings(orgId) : undefined;
153+
private async updateOrganizationPermissions(
154+
orgId: string | undefined,
155+
options?: { force?: boolean },
156+
): Promise<void> {
157+
const settings = orgId != null ? await this.getOrganizationSettings(orgId, options) : undefined;
147158
let aiProviders;
148159
try {
149160
aiProviders = fromGKDevAIProviders(settings?.aiProviders);

0 commit comments

Comments
 (0)