@@ -34,6 +34,7 @@ export class OrganizationService implements Disposable {
34
34
const orgId = await this . getActiveOrganizationId ( ) ;
35
35
void this . updateOrganizationPermissions ( orgId ) ;
36
36
} ) ,
37
+ container . subscription . onDidCheckIn ( this . onUserCheckedIn , this ) ,
37
38
container . subscription . onDidChange ( this . onSubscriptionChanged , this ) ,
38
39
) ;
39
40
}
@@ -128,11 +129,19 @@ export class OrganizationService implements Disposable {
128
129
} ) ;
129
130
}
130
131
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
+
131
139
private async onSubscriptionChanged ( e : SubscriptionChangeEvent ) : Promise < void > {
132
140
if ( e . current ?. account ?. id == null ) {
133
141
this . updateOrganizations ( undefined ) ;
142
+ this . _organizationSettings = undefined ;
143
+ await this . clearAllStoredOrganizationsSettings ( ) ;
134
144
}
135
- await this . clearAllStoredOrganizationsSettings ( ) ;
136
145
await this . updateOrganizationPermissions ( e . current ?. activeOrganization ?. id ) ;
137
146
}
138
147
@@ -141,8 +150,11 @@ export class OrganizationService implements Disposable {
141
150
void setContext ( 'gitlens:gk:hasOrganizations' , ( organizations ?? [ ] ) . length > 1 ) ;
142
151
}
143
152
144
- private async updateOrganizationPermissions ( orgId : string | undefined ) : Promise < void > {
145
- 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 ;
146
158
let aiProviders ;
147
159
try {
148
160
aiProviders = fromGKDevAIProviders ( settings ?. aiProviders ) ;
@@ -274,7 +286,7 @@ export class OrganizationService implements Disposable {
274
286
}
275
287
276
288
private async clearAllStoredOrganizationsSettings ( ) : Promise < void > {
277
- return this . container . storage . deleteWithPrefix ( `plus:organization: ` ) ;
289
+ return this . container . storage . deleteWithPrefix ( `plus:organization` ) ;
278
290
}
279
291
280
292
private async deleteStoredOrganizationSettings ( id : string ) : Promise < void > {
0 commit comments