Skip to content

Commit fc5606c

Browse files
authored
feat: select org profile on sign in (#8859)
* feat: select org profile on sign in * reset inside cascade init * reset only when personl
1 parent a20e112 commit fc5606c

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

core/config/ConfigHandler.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export class ConfigHandler {
100100
return `${workspaceId}:::${orgId}`;
101101
}
102102

103-
private async cascadeInit(reason: string) {
103+
private async cascadeInit(reason: string, isLogin?: boolean) {
104104
const signal = this.cascadeAbortController.signal;
105105
this.workspaceDirs = null; // forces workspace dirs reload
106106

@@ -118,7 +118,12 @@ export class ConfigHandler {
118118
const workspaceId = await this.getWorkspaceId();
119119
const selectedOrgs =
120120
this.globalContext.get("lastSelectedOrgIdForWorkspace") ?? {};
121-
const currentSelection = selectedOrgs[workspaceId];
121+
let currentSelection = selectedOrgs[workspaceId];
122+
123+
// reset personal org to first available non-personal org on login
124+
if (isLogin && currentSelection === "personal") {
125+
currentSelection = null;
126+
}
122127

123128
const firstNonPersonal = orgs.find(
124129
(org) => org.id !== this.PERSONAL_ORG_DESC.id,
@@ -402,6 +407,7 @@ export class ConfigHandler {
402407
const newSession = sessionInfo;
403408

404409
let reload = false;
410+
let isLogin = false;
405411
if (newSession) {
406412
if (currentSession) {
407413
if (
@@ -416,6 +422,7 @@ export class ConfigHandler {
416422
} else {
417423
// log in
418424
reload = true;
425+
isLogin = true;
419426
}
420427
} else {
421428
if (currentSession) {
@@ -430,7 +437,7 @@ export class ConfigHandler {
430437
this.ide,
431438
);
432439
this.abortCascade();
433-
await this.cascadeInit("Control plane session info update");
440+
await this.cascadeInit("Control plane session info update", isLogin);
434441
}
435442
return reload;
436443
}

0 commit comments

Comments
 (0)