The best way to control Claude Code, Codex and more from any computer or phone
| 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 | issueListPreferences, |
| 8 | IssueListPreferencesSchema, |
| 9 | type IssueListPreferences, |
| 10 | } from "./issueListPreferences"; |
| 11 | |
| 12 | export function issueViewMatches( |
| 13 | view: SavedView<typeof IssueListPreferencesSchema.Type>, |
| 14 | preferences: IssueListPreferences, |
| 15 | ): boolean { |
| 16 | const key = (value: IssueListPreferences) => { |
| 17 | const normalized = issueListPreferences(value); |
| 18 | return JSON.stringify({ |
| 19 | ...normalized, |
| 20 | label: normalized.label?.toSorted(), |
| 21 | hideProjects: normalized.hideProjects?.map((pair) => JSON.stringify(pair)).toSorted(), |
| 22 | }); |
| 23 | }; |
| 24 | return key(issueListPreferences(view.preferences)) === key(preferences); |
| 25 | } |
| 26 | |
| 27 | export const ISSUE_SAVED_VIEWS = { |
| 28 | storageKey: "t3.issues.savedViews", |
| 29 | schema: Schema.Array( |
| 30 | Schema.Struct({ ...SavedViewIdentity.fields, preferences: IssueListPreferencesSchema }), |
| 31 | ), |
| 32 | empty: [], |
| 33 | list: "issue", |
| 34 | placeholder: msg("Issues Assigned to Me"), |
| 35 | suggestedName: (preferences) => |
| 36 | preferences.who === "assigned" ? msg("Issues Assigned to Me") : "", |
| 37 | normalize: issueListPreferences, |
| 38 | matches: issueViewMatches, |
| 39 | } as const satisfies SavedViewsKind< |
| 40 | IssueListPreferences, |
| 41 | typeof IssueListPreferencesSchema.Type, |
| 42 | unknown |
| 43 | >; |