| 53 | } |
| 54 | |
| 55 | async function syncWorkspace() { |
| 56 | const listed = await sdk.client.experimental.workspace.list().catch(() => undefined) |
| 57 | if (!listed?.data) return |
| 58 | const status = await sdk.client.experimental.workspace.status().catch(() => undefined) |
| 59 | const next = Object.fromEntries((status?.data ?? []).map((item) => [item.workspaceID, item.status])) |
| 60 | |
| 61 | batch(() => { |
| 62 | setStore("workspace", "list", reconcile(listed.data)) |
| 63 | setStore("workspace", "status", reconcile(next)) |
| 64 | if (!listed.data.some((item) => item.id === store.workspace.current)) { |
| 65 | setStore("workspace", "current", undefined) |
| 66 | } |
| 67 | }) |
| 68 | } |
| 69 | |
| 70 | sdk.event.on("event", (event) => { |
| 71 | if (event.payload.type === "workspace.status") { |