@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 44 lines 1.42 KB
Raw
1 import type { Preferences, PullRequestSavedView } from "../../persistence/mobile-preferences";
2
3 export type PullRequestSavedViewScope = Pick<
4 PullRequestSavedView,
5 "environmentId" | "controls" | "query"
6 >;
7
8 export function pullRequestViewMatches(
9 view: PullRequestSavedViewScope,
10 scope: PullRequestSavedViewScope,
11 ) {
12 const key = ({ environmentId, controls, query }: PullRequestSavedViewScope) =>
13 JSON.stringify([
14 environmentId,
15 query.trim(),
16 controls.state,
17 controls.involvement,
18 controls.sort,
19 controls.projectId,
20 controls.projectEnvironmentId,
21 controls.filters.draft,
22 controls.filters.review,
23 controls.filters.checks,
24 controls.filters.author,
25 controls.filters.labels
26 ?.map((group) => [...group].sort())
27 .sort((a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b))),
28 controls.filters.excludedLabels ? [...controls.filters.excludedLabels].sort() : undefined,
29 ]);
30 return key(view) === key(scope);
31 }
32
33 /** Apply environment and controls in one preference write, retaining other environments' controls. */
34 export function pullRequestSavedViewPreferences(current: Preferences, view: PullRequestSavedView) {
35 return {
36 pullRequestListFilters: {
37 environmentId: view.environmentId,
38 controls: {
39 ...current.pullRequestListFilters?.controls,
40 [view.environmentId ?? ""]: view.controls,
41 },
42 },
43 };
44 }