fix deeplink handling

This commit is contained in:
Dallin Romney
2025-04-06 15:31:05 -07:00
parent b8c6fc400e
commit 3039592d24
4 changed files with 16 additions and 17 deletions

View File

@@ -328,7 +328,7 @@ export class ConfigHandler {
}
// Org id: check id validity, save selection, switch and reload
async setSelectedOrgId(orgId: string) {
async setSelectedOrgId(orgId: string, profileId?: string) {
if (orgId === this.currentOrg.id) {
return;
}
@@ -346,8 +346,13 @@ export class ConfigHandler {
});
this.currentOrg = org;
this.currentProfile = org.currentProfile;
await this.reloadConfig();
if (profileId) {
this.setSelectedProfileId(profileId);
} else {
this.currentProfile = org.currentProfile;
await this.reloadConfig();
}
}
// Profile id: check id validity, save selection, switch and reload

View File

@@ -819,7 +819,10 @@ export class Core {
});
on("didChangeSelectedOrg", async (msg) => {
await this.configHandler.setSelectedOrgId(msg.data.id);
await this.configHandler.setSelectedOrgId(
msg.data.id,
msg.data.profileId,
);
});
on("didChangeControlPlaneSessionInfo", async (msg) => {

View File

@@ -3,6 +3,6 @@ import { ToWebviewFromIdeOrCoreProtocol } from "./webview.js";
export type ToCoreFromWebviewProtocol = ToCoreFromIdeOrWebviewProtocol & {
didChangeSelectedProfile: [{ id: string }, void];
didChangeSelectedOrg: [{ id: string }, void];
didChangeSelectedOrg: [{ id: string; profileId?: string }, void];
};
export type ToWebviewFromCoreProtocol = ToWebviewFromIdeOrCoreProtocol;

View File

@@ -202,16 +202,10 @@ export class VsCodeExtension {
let profileId = queryParams.get("profile_id");
let orgId = queryParams.get("org_id");
if (orgId) {
if (orgId === "null") {
orgId = null;
}
if (orgId && orgId !== "null") {
// In case org id is passed with profile id
// Make sure org is updated before profile is set
if (profileId) {
if (profileId === "null") {
profileId = null;
}
if (profileId && profileId !== "null") {
this.core.invoke("didChangeSelectedOrg", {
id: orgId,
profileId,
@@ -221,10 +215,7 @@ export class VsCodeExtension {
id: orgId,
});
}
} else if (profileId) {
if (profileId === "null") {
profileId = null;
}
} else if (profileId && profileId !== "null") {
this.core.invoke("didChangeSelectedProfile", {
id: profileId,
});