Skip to content

Commit aebeaf2

Browse files
committed
fix(store): adds untrack and proper short-circuit to pruning
1 parent b325045 commit aebeaf2

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

src/app/stores/view.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { z } from "zod";
22
import { createStore, produce } from "solid-js/store";
3-
import { createEffect, onCleanup } from "solid-js";
3+
import { createEffect, onCleanup, untrack } from "solid-js";
44

55
export const VIEW_STORAGE_KEY = "github-tracker:view";
66

@@ -240,15 +240,15 @@ export function pruneExpandedRepos(
240240
tab: keyof ViewState["expandedRepos"],
241241
activeRepoNames: string[]
242242
): void {
243-
if (Object.keys(viewState.expandedRepos[tab]).length === 0) return;
243+
const currentKeys = untrack(() => Object.keys(viewState.expandedRepos[tab]));
244+
if (currentKeys.length === 0) return;
244245
const activeSet = new Set(activeRepoNames);
246+
const staleKeys = currentKeys.filter((k) => !activeSet.has(k));
247+
if (staleKeys.length === 0) return;
245248
setViewState(
246249
produce((draft) => {
247-
const keys = Object.keys(draft.expandedRepos[tab]);
248-
for (const key of keys) {
249-
if (!activeSet.has(key)) {
250-
delete draft.expandedRepos[tab][key];
251-
}
250+
for (const key of staleKeys) {
251+
delete draft.expandedRepos[tab][key];
252252
}
253253
})
254254
);

tests/components/DashboardPage.test.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,7 @@ beforeEach(async () => {
117117
errors: [],
118118
});
119119
// Reset view store to defaults
120-
viewStore.updateViewState({
121-
lastActiveTab: "issues",
122-
sortPreferences: {},
123-
ignoredItems: [],
124-
globalFilter: { org: null, repo: null },
125-
});
120+
viewStore.resetViewState();
126121
});
127122

128123
describe("DashboardPage — tab switching", () => {

0 commit comments

Comments
 (0)