Skip to content

Commit 6364228

Browse files
committed
Fix logout check
We have to check storage again, otherwise we are just checking the values we already checked.
1 parent b4f046b commit 6364228

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/workspacesProvider.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,25 @@ export class WorkspaceProvider implements vscode.TreeDataProvider<vscode.TreeIte
5858

5959
const resp = await getWorkspaces({ q: this.getWorkspacesQuery })
6060

61-
// We could have logged out while waiting for the query.
62-
if (!url || !token) {
61+
// We could have logged out while waiting for the query, or logged into a
62+
// different deployment.
63+
const url2 = this.storage.getURL()
64+
const token2 = await this.storage.getSessionToken()
65+
if (!url2 || !token2) {
6366
throw new Error("not logged in")
67+
} else if (url !== url2) {
68+
// In this case we need to fetch from the new deployment instead.
69+
// TODO: It would be better to cancel this fetch when that happens,
70+
// because this means we have to wait for the old fetch to finish before
71+
// finally getting workspaces for the new one.
72+
return this.fetch()
6473
}
6574

6675
return resp.workspaces.map((workspace) => {
6776
const showMetadata = this.getWorkspacesQuery === WorkspaceQuery.Mine
6877
if (showMetadata) {
6978
const agents = extractAgents(workspace)
70-
agents.forEach((agent) => this.monitorMetadata(agent.id, url, token)) // monitor metadata for all agents
79+
agents.forEach((agent) => this.monitorMetadata(agent.id, url, token2)) // monitor metadata for all agents
7180
}
7281
return new WorkspaceTreeItem(workspace, this.getWorkspacesQuery === WorkspaceQuery.All, showMetadata)
7382
})

0 commit comments

Comments
 (0)