@devries-cameron20 / t3code Mirror · read-only / commits / ecb35f7583
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 24, 21:30 UTC

Fix Legal modal header crash (#4000)

Co-authored-by: codex <codex@users.noreply.github.com>

Julius Marminge committed Jul 15, 2026 at 12:48 UTC ecb35f75839925dd1ac6f854efeef5c9e291d11b
2 files changed +22 -21
apps/mobile/src/Stack.tsx
+1 -1
@@ -115,7 +115,7 @@ const LEGAL_DOCUMENT_HEADER_OPTIONS: AppScreenOptions = {
115 ...SHEET_SOLID_HEADER_OPTIONS,
116 headerBackVisible: false,
117 headerLeft: SettingsLegalDocumentCloseHeaderButton,
118 - headerRight: SettingsLegalDocumentExternalHeaderButton,
118 + headerRight: () => <SettingsLegalDocumentExternalHeaderButton />,
119 presentation: "fullScreenModal",
120 };
121
apps/mobile/src/features/settings/components/SettingsLegalDocumentRouteScreen.tsx
+21 -20
@@ -1,11 +1,5 @@
1 -import {
2 - type NavigationProp,
3 - type ParamListBase,
4 - type RouteProp,
5 - useNavigation,
6 - useRoute,
7 -} from "@react-navigation/native";
8 -import { useCallback, useState } from "react";
1 +import { type NavigationProp, type ParamListBase, useNavigation } from "@react-navigation/native";
2 +import { useCallback, useLayoutEffect, useState } from "react";
3 import { ActivityIndicator, Linking, Pressable, View } from "react-native";
4 import { WebView } from "react-native-webview";
5
@@ -15,10 +9,6 @@ import { SymbolView } from "../../../components/AppSymbol";
9 import { useThemeColor } from "../../../lib/useThemeColor";
10 import { isLegalDocumentUrl, LEGAL_URL } from "../lib/legal-document-url";
11
18 -type SettingsLegalRouteParams = {
19 - SettingsLegal: { readonly externalUrl?: string } | undefined;
20 -};
21 -
12 export function SettingsLegalDocumentCloseHeaderButton() {
13 const navigation = useNavigation();
14 const iconColor = useThemeColor("--color-icon");
@@ -42,20 +32,20 @@ export function SettingsLegalDocumentCloseHeaderButton() {
32 );
33 }
34
45 -export function SettingsLegalDocumentExternalHeaderButton() {
35 +export function SettingsLegalDocumentExternalHeaderButton({
36 + externalUrl = LEGAL_URL,
37 +}: {
38 + readonly externalUrl?: string;
39 +}) {
40 const iconColor = useThemeColor("--color-icon");
47 - const route = useRoute<RouteProp<SettingsLegalRouteParams, "SettingsLegal">>();
48 - const externalUrl =
49 - route.params?.externalUrl && isLegalDocumentUrl(route.params.externalUrl)
50 - ? route.params.externalUrl
51 - : LEGAL_URL;
41 + const safeExternalUrl = isLegalDocumentUrl(externalUrl) ? externalUrl : LEGAL_URL;
42
43 return (
44 <Pressable
45 accessibilityLabel="Open legal documents in external browser"
46 accessibilityRole="button"
47 hitSlop={12}
58 - onPress={() => void Linking.openURL(externalUrl).catch(() => undefined)}
48 + onPress={() => void Linking.openURL(safeExternalUrl).catch(() => undefined)}
49 className="p-2 active:opacity-60"
50 >
51 <SymbolView
@@ -83,6 +73,17 @@ export function SettingsLegalDocumentRouteScreen({
73 const [reloadKey, setReloadKey] = useState(0);
74 const [loadProgress, setLoadProgress] = useState(0);
75 const [loadError, setLoadError] = useState<string | null>(null);
76 + const [externalUrl, setExternalUrl] = useState(documentUrl);
77 + const renderExternalHeaderButton = useCallback(
78 + () => <SettingsLegalDocumentExternalHeaderButton externalUrl={externalUrl} />,
79 + [externalUrl],
80 + );
81 +
82 + useLayoutEffect(() => {
83 + navigation.setOptions({
84 + headerRight: renderExternalHeaderButton,
85 + });
86 + }, [navigation, renderExternalHeaderButton]);
87
88 const openExternalUrl = useCallback((url: string) => {
89 void Linking.openURL(url).catch(() => undefined);
@@ -160,7 +161,7 @@ export function SettingsLegalDocumentRouteScreen({
161 }}
162 onLoadEnd={(event) => {
163 if (isLegalDocumentUrl(event.nativeEvent.url)) {
163 - navigation.setParams({ externalUrl: event.nativeEvent.url });
164 + setExternalUrl(event.nativeEvent.url);
165 }
166 setLoadProgress(0);
167 }}