Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix: preserve caches positively scoped to another workspace

Tina934450fdd5b
diff --git a/apps/web/src/lib/evict-workspace-cache.test.ts b/apps/web/src/lib/evict-workspace-cache.test.ts
index 062d3f883..59db5e22f 100644
--- a/apps/web/src/lib/evict-workspace-cache.test.ts
+++ b/apps/web/src/lib/evict-workspace-cache.test.ts
@@ -13,6 +13,11 @@ it("evicts revoked and unscoped private data while preserving another workspace'
});
const active = { id: "active-project", workspaceId: "active", columns: [] };
client.setQueryData(["tasks", "active-project"], active);
+ client.setQueryData(["projects", "active"], [active]);
+ client.setQueryData(
+ ["projects", "revoked"],
+ [{ id: "revoked-project", workspaceId: "revoked" }],
+ );
client.setQueryData(["task", "revoked-task"], {
id: "revoked-task",
projectId: "revoked-project",
@@ -25,6 +30,8 @@ it("evicts revoked and unscoped private data while preserving another workspace'
});
evictWorkspaceCache(client, "revoked");
expect(client.getQueryData(["tasks", "active-project"])).toEqual(active);
+ expect(client.getQueryData(["projects", "active"])).toEqual([active]);
+ expect(client.getQueryData(["projects", "revoked"])).toBeUndefined();
expect(client.getQueryData(["tasks", "revoked-project"])).toBeUndefined();
expect(client.getQueryData(["task", "revoked-task"])).toBeUndefined();
expect(client.getQueryData(["task", "unscoped"])).toBeUndefined();
diff --git a/apps/web/src/lib/evict-workspace-cache.ts b/apps/web/src/lib/evict-workspace-cache.ts
index 40a2c16cf..f9dae32e7 100644
--- a/apps/web/src/lib/evict-workspace-cache.ts
+++ b/apps/web/src/lib/evict-workspace-cache.ts
@@ -19,6 +19,8 @@ export function evictWorkspaceCache(client: QueryClient, workspaceId: string) {
};
for (const query of queries)
visit(query.state.data, (record) => {
+ if (typeof record.workspaceId === "string")
+ scopes.set(record.workspaceId, record.workspaceId);
if (
typeof record.workspaceId === "string" &&
typeof record.id === "string"