Skip to content

Commit 3a74bc9

Browse files
committed
fix: Increase debug actionsheet tap
1 parent 19c6e48 commit 3a74bc9

File tree

2 files changed

+75
-5
lines changed

2 files changed

+75
-5
lines changed

components/debug-provider.tsx

+72-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useLogout } from "@/features/authentication/use-logout.hook";
33
import { translate } from "@/i18n";
44
import { navigate } from "@/navigation/navigation.utils";
55
import { $globalStyles } from "@/theme/styles";
6+
import { getEnv } from "@/utils/getEnv";
67
import { getNativeLogFile } from "@/utils/xmtpRN/logs";
78
import * as Sentry from "@sentry/react-native";
89
import {
@@ -23,6 +24,8 @@ export function DebugProvider(props: { children: React.ReactNode }) {
2324

2425
const { logout } = useLogout();
2526

27+
const { currentlyRunning } = Updates.useUpdates();
28+
2629
const methods = useMemo(() => {
2730
// Debug menu options and their corresponding actions
2831
const debugMethods = {
@@ -65,6 +68,70 @@ export function DebugProvider(props: { children: React.ReactNode }) {
6568
);
6669
alert("Done!");
6770
},
71+
"Show App Info": () => {
72+
const appVersion = Constants.expoConfig?.version;
73+
const buildNumber =
74+
Platform.OS === "ios"
75+
? Constants.expoConfig?.ios?.buildNumber
76+
: Constants.expoConfig?.android?.versionCode;
77+
const environment = getEnv();
78+
79+
Alert.alert(
80+
"App Information",
81+
[
82+
`Version: ${appVersion}`,
83+
`Build: ${buildNumber}`,
84+
`Environment: ${environment}`,
85+
`Update ID: ${currentlyRunning.updateId || "embedded"}`,
86+
`Created At: ${
87+
currentlyRunning.createdAt?.toLocaleString() || "N/A"
88+
}`,
89+
`Runtime Version: ${currentlyRunning.runtimeVersion}`,
90+
`Channel: ${currentlyRunning.channel || "N/A"}`,
91+
`Is Embedded: ${currentlyRunning.isEmbeddedLaunch}`,
92+
currentlyRunning.isEmergencyLaunch ? `Emergency Launch: Yes` : "",
93+
currentlyRunning.emergencyLaunchReason
94+
? `Emergency Reason: ${currentlyRunning.emergencyLaunchReason}`
95+
: "",
96+
]
97+
.filter(Boolean)
98+
.join("\n")
99+
);
100+
},
101+
"Check for Updates": async () => {
102+
try {
103+
const update = await Updates.checkForUpdateAsync();
104+
if (update.isAvailable) {
105+
Alert.alert(
106+
"Update Available",
107+
"Would you like to download and install the update?",
108+
[
109+
{
110+
text: "Cancel",
111+
style: "cancel",
112+
},
113+
{
114+
text: "Update",
115+
onPress: async () => {
116+
try {
117+
const fetchedUpdate = await Updates.fetchUpdateAsync();
118+
if (fetchedUpdate.isNew) {
119+
await Updates.reloadAsync();
120+
}
121+
} catch (error) {
122+
Alert.alert("Error", JSON.stringify(error));
123+
}
124+
},
125+
},
126+
]
127+
);
128+
} else {
129+
Alert.alert("No Updates", "You are running the latest version");
130+
}
131+
} catch (error) {
132+
Alert.alert("Error", JSON.stringify(error));
133+
}
134+
},
68135
};
69136

70137
return {
@@ -112,7 +179,7 @@ export function DebugProvider(props: { children: React.ReactNode }) {
112179
},
113180
Cancel: undefined,
114181
};
115-
}, [logout]);
182+
}, [logout, currentlyRunning]);
116183

117184
const showDebugMenu = useCallback(() => {
118185
const options = Object.keys(methods);
@@ -151,13 +218,13 @@ export function DebugProvider(props: { children: React.ReactNode }) {
151218
clearTimeout(tapTimeoutRef.current);
152219
}
153220

154-
// Set new timeout to reset count after 2 seconds
221+
// Set new timeout to reset count after 500ms
155222
tapTimeoutRef.current = setTimeout(() => {
156223
tapCountRef.current = 0;
157-
}, 2000);
224+
}, 500);
158225

159-
// Show debug menu after 4 taps
160-
if (tapCountRef.current >= 4) {
226+
// Show debug menu after 5 taps
227+
if (tapCountRef.current >= 5) {
161228
showDebugMenu();
162229
tapCountRef.current = 0;
163230
}

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44
"private": true,
55
"scripts": {
66
"start": "expo start",
7+
"start:preview": "EXPO_ENV=preview expo start",
78
"android": "expo run:android",
89
"android:clean": "expo prebuild --clean -p android && yarn android",
910
"android:build:dev": "npx eas-cli build -p android --profile development --local",
1011
"android:reverse": "adb reverse tcp:8081 tcp:8081 && adb reverse tcp:9875 tcp:9875",
1112
"android:sendApk": "./scripts/android/send-apk.sh",
1213
"ios": "expo run:ios",
14+
"ios:preview": "EXPO_ENV=preview expo run:ios",
15+
"ios:preview:clean": "EXPO_ENV=preview expo prebuild --clean -p ios && yarn ios:preview",
1316
"ios:clean": "expo prebuild --clean -p ios && yarn ios",
1417
"env:pull:dev": "npx eas-cli env:pull --environment=development",
1518
"env:pull:preview": "npx eas-cli env:pull --environment=preview",

0 commit comments

Comments
 (0)