Skip to content

Commit de59b59

Browse files
committed
Remove unused gitCreateBranchMutationOptions and prune stale entries in useGitStatuses
1 parent 00d879b commit de59b59

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

apps/web/src/lib/gitReactQuery.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -206,24 +206,6 @@ export function gitRemoveWorktreeMutationOptions(input: { queryClient: QueryClie
206206
},
207207
});
208208
}
209-
210-
export function gitCreateBranchMutationOptions(input: {
211-
cwd: string | null;
212-
queryClient: QueryClient;
213-
}) {
214-
return mutationOptions({
215-
mutationKey: ["git", "mutation", "create-branch", input.cwd] as const,
216-
mutationFn: async (branch: string) => {
217-
const api = ensureNativeApi();
218-
if (!input.cwd) throw new Error("Git branch creation is unavailable.");
219-
return api.git.createBranch({ cwd: input.cwd, branch });
220-
},
221-
onSuccess: async () => {
222-
await invalidateGitBranchQueries(input.queryClient, input.cwd);
223-
},
224-
});
225-
}
226-
227209
export function gitPreparePullRequestThreadMutationOptions(input: {
228210
cwd: string | null;
229211
queryClient: QueryClient;

apps/web/src/lib/gitStatusState.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,24 @@ export function useGitStatuses(cwds: ReadonlyArray<string>): ReadonlyMap<string,
9090
);
9191

9292
useEffect(() => {
93+
const cwdSet = new Set(cwds);
94+
95+
setStatusByCwd((current) => {
96+
let pruned = false;
97+
for (const key of current.keys()) {
98+
if (!cwdSet.has(key)) {
99+
pruned = true;
100+
break;
101+
}
102+
}
103+
if (!pruned) return current;
104+
const next = new Map<string, GitStatusResult>();
105+
for (const [key, value] of current) {
106+
if (cwdSet.has(key)) next.set(key, value);
107+
}
108+
return next;
109+
});
110+
93111
const cleanups = cwds.map((cwd) =>
94112
appAtomRegistry.subscribe(
95113
gitStatusStateAtom(cwd),

0 commit comments

Comments
 (0)