Merge pull request #6910 from continuedev/dallin/handle-session-changes
fix: only update on session change when needed
This commit is contained in:
commit
e93842d7a1
2 changed files with 37 additions and 10 deletions
|
|
@ -363,13 +363,42 @@ export class ConfigHandler {
|
|||
async updateControlPlaneSessionInfo(
|
||||
sessionInfo: ControlPlaneSessionInfo | undefined,
|
||||
) {
|
||||
this.controlPlaneClient = new ControlPlaneClient(
|
||||
Promise.resolve(sessionInfo),
|
||||
this.ideSettingsPromise,
|
||||
this.ide.getIdeInfo(),
|
||||
);
|
||||
this.abortCascade();
|
||||
await this.cascadeInit("Control plane session info update");
|
||||
const currentSession = await this.controlPlaneClient.sessionInfoPromise;
|
||||
const newSession = sessionInfo;
|
||||
|
||||
let reload = false;
|
||||
if (newSession) {
|
||||
if (currentSession) {
|
||||
if (
|
||||
newSession.AUTH_TYPE !== AuthType.OnPrem &&
|
||||
currentSession.AUTH_TYPE !== AuthType.OnPrem
|
||||
) {
|
||||
if (newSession.account.id !== currentSession.account.id) {
|
||||
// session id change (non-on-prem)
|
||||
reload = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// log in
|
||||
reload = true;
|
||||
}
|
||||
} else {
|
||||
if (currentSession) {
|
||||
// log out
|
||||
reload = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (reload) {
|
||||
this.controlPlaneClient = new ControlPlaneClient(
|
||||
Promise.resolve(sessionInfo),
|
||||
this.ideSettingsPromise,
|
||||
this.ide.getIdeInfo(),
|
||||
);
|
||||
this.abortCascade();
|
||||
await this.cascadeInit("Control plane session info update");
|
||||
}
|
||||
return reload;
|
||||
}
|
||||
|
||||
// Org id: check id validity, save selection, switch and reload
|
||||
|
|
|
|||
|
|
@ -36,9 +36,7 @@ export const TRIAL_PROXY_URL =
|
|||
|
||||
export class ControlPlaneClient {
|
||||
constructor(
|
||||
private readonly sessionInfoPromise: Promise<
|
||||
ControlPlaneSessionInfo | undefined
|
||||
>,
|
||||
readonly sessionInfoPromise: Promise<ControlPlaneSessionInfo | undefined>,
|
||||
private readonly ideSettingsPromise: Promise<IdeSettings>,
|
||||
private readonly ideInfoPromise: Promise<IdeInfo>,
|
||||
) {}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue