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
| 1 | import type { EnvironmentThreadShell } from "@t3tools/client-runtime/state/shell"; |
| 2 | import { useNavigation } from "@react-navigation/native"; |
| 3 | import { useGT } from "gt-react-native"; |
| 4 | import { changeRequestTermKind } from "../../lib/changeRequestTerm"; |
| 5 | |
| 6 | import * as Dialog from "../../components/ui/Dialog"; |
| 7 | import { useNavigateToPullRequest } from "../../native/useOpenPullRequest"; |
| 8 | import { |
| 9 | resolveThreadPrBadgeAction, |
| 10 | type ThreadPrPresentation, |
| 11 | } from "../../state/thread-pr-presentation"; |
| 12 | |
| 13 | /** Called once per thread list so virtualized rows share one stable handler. */ |
| 14 | export function useOpenThreadPullRequests() { |
| 15 | const gt = useGT(); |
| 16 | const navigation = useNavigation(); |
| 17 | const navigateToPullRequest = useNavigateToPullRequest(); |
| 18 | return (thread: EnvironmentThreadShell, pr: ThreadPrPresentation) => { |
| 19 | if (resolveThreadPrBadgeAction(pr).kind === "list") { |
| 20 | navigation.navigate("ThreadPullRequests", { |
| 21 | environmentId: String(thread.environmentId), |
| 22 | threadId: String(thread.id), |
| 23 | }); |
| 24 | return; |
| 25 | } |
| 26 | void navigateToPullRequest(pr.url, { |
| 27 | environmentId: String(thread.environmentId), |
| 28 | projectId: String(thread.projectId), |
| 29 | }).then((opened) => { |
| 30 | if (!opened) |
| 31 | Dialog.alert( |
| 32 | gt( |
| 33 | "{term, select, mr {Unable to open MR} cr {Unable to open change request} other {Unable to open PR}}", |
| 34 | { term: changeRequestTermKind(pr.changeRequest) }, |
| 35 | ), |
| 36 | gt( |
| 37 | "{term, select, mr {The merge request could not be opened.} cr {The change request could not be opened.} other {The pull request could not be opened.}}", |
| 38 | { |
| 39 | term: changeRequestTermKind(pr.changeRequest), |
| 40 | }, |
| 41 | ), |
| 42 | ); |
| 43 | }); |
| 44 | }; |
| 45 | } |