@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 63 lines 2.13 KB
Raw
1 import * as Schema from "effect/Schema";
2 import { msg } from "gt-react";
3 import { SavedViewIdentity } from "@t3tools/client-runtime/saved-views";
4
5 import type { SavedView, SavedViewsKind } from "../SavedViewsMenu";
6 import {
7 pullRequestListPreferences,
8 PullRequestListPreferencesSchema,
9 type PullRequestListPreferencePatch,
10 type PullRequestListPreferences,
11 } from "./pullRequestListPreferences";
12
13 export function pullRequestViewMatches(
14 view: SavedView<typeof PullRequestListPreferencesSchema.Type>,
15 preferences: PullRequestListPreferences,
16 ): boolean {
17 const key = (value: PullRequestListPreferences) => {
18 const normalized = pullRequestListPreferences(value);
19 return JSON.stringify({
20 ...normalized,
21 labels: normalized.labels?.toSorted(),
22 });
23 };
24 return key(pullRequestListPreferences(view.preferences)) === key(preferences);
25 }
26
27 export const PULL_REQUEST_SAVED_VIEWS = {
28 storageKey: "t3.pullRequests.savedViews",
29 schema: Schema.Array(
30 Schema.Struct({ ...SavedViewIdentity.fields, preferences: PullRequestListPreferencesSchema }),
31 ),
32 empty: [],
33 list: "pullRequest",
34 placeholder: msg("PRs Requesting My Review"),
35 suggestedName: (preferences) =>
36 preferences.involvement === "reviewing" ? msg("PRs Requesting My Review") : "",
37 normalize: pullRequestListPreferences,
38 matches: pullRequestViewMatches,
39 } as const satisfies SavedViewsKind<
40 PullRequestListPreferences,
41 typeof PullRequestListPreferencesSchema.Type,
42 unknown
43 >;
44
45 /** Explicit clears replace the old list scope without touching the independently selected PR. */
46 export function pullRequestSavedViewPatch(
47 preferences: PullRequestListPreferences,
48 ): PullRequestListPreferencePatch & Pick<PullRequestListPreferences, "involvement" | "state"> {
49 return {
50 involvement: preferences.involvement,
51 state: preferences.state,
52 environmentId: preferences.environmentId,
53 projectId: preferences.projectId,
54 host: preferences.host,
55 q: preferences.q,
56 draft: preferences.draft,
57 review: preferences.review,
58 checks: preferences.checks,
59 author: preferences.author,
60 labels: preferences.labels,
61 sort: preferences.sort,
62 };
63 }