Skip to content

Commit 9ccf6d9

Browse files
perf(mobile): settings screens compile with the React Compiler
About, Environments, Environment detail, Notifications, Project overview and Provider accounts were skipped for try/finally and try without catch. Cleanup now runs from .finally() or after the awaited atom command settles, and their manual useCallback/useMemo are gone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 8f02648 commit 9ccf6d9

7 files changed

Lines changed: 161 additions & 211 deletions

‎apps/mobile/src/features/settings/SettingsAboutRouteScreen.tsx‎

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as Dialog from "../../components/ui/Dialog";
22
import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView";
33
import Constants from "expo-constants";
4-
import { useCallback, useEffect, useRef, useState } from "react";
4+
import { useEffect, useRef, useState } from "react";
55
import { Pressable, View } from "react-native";
66
import { useSafeAreaInsets } from "react-native-safe-area-context";
77

@@ -56,30 +56,28 @@ function AppSettingsSection() {
5656
return () => clearTimeout(timer);
5757
}, [updateState]);
5858

59-
const checkForUpdate = useCallback(async () => {
59+
function checkForUpdate() {
6060
// `disabled={busy}` only takes effect on the next render, so two taps in the
6161
// same frame would both get through. The ref closes that window.
6262
if (updateInFlight.current) return;
6363
updateInFlight.current = true;
64-
try {
65-
await runAppUpdateCheck({
66-
applyMode: "immediate",
67-
onFailure: (message) => Dialog.alert("Update failed", message),
68-
onStateChange: setUpdateState,
69-
});
70-
} finally {
64+
void runAppUpdateCheck({
65+
applyMode: "immediate",
66+
onFailure: (message) => Dialog.alert("Update failed", message),
67+
onStateChange: setUpdateState,
68+
}).finally(() => {
7169
updateInFlight.current = false;
72-
}
73-
}, []);
70+
});
71+
}
7472

75-
const handleVersionPress = useCallback(() => {
73+
function handleVersionPress() {
7674
if (!updateCheckAvailable || updateInFlight.current) return;
7775
const tap = registerHiddenUpdateTap(hiddenUpdateTapCount.current);
7876
hiddenUpdateTapCount.current = tap.nextCount;
7977
if (tap.shouldCheck) {
80-
void checkForUpdate();
78+
checkForUpdate();
8179
}
82-
}, [checkForUpdate, updateCheckAvailable]);
80+
}
8381

8482
const statusLabel =
8583
updateState === "checking"

‎apps/mobile/src/features/settings/SettingsEnvironmentDetailRouteScreen.tsx‎

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,16 @@ function EnvironmentDetail({ environmentId }: { readonly environmentId: Environm
9696
setPending(label);
9797
setError(null);
9898
setNotice(null);
99-
try {
100-
await action();
101-
} catch (cause) {
102-
setError(
103-
cause instanceof Error ? cause.message : "The action could not be completed. Try again.",
104-
);
105-
} finally {
106-
pendingRef.current = false;
107-
setPending(null);
108-
}
99+
await action()
100+
.catch((cause: unknown) => {
101+
setError(
102+
cause instanceof Error ? cause.message : "The action could not be completed. Try again.",
103+
);
104+
})
105+
.finally(() => {
106+
pendingRef.current = false;
107+
setPending(null);
108+
});
109109
}
110110

111111
function requestServerUpdate() {
@@ -268,19 +268,15 @@ function EnvironmentDetail({ environmentId }: { readonly environmentId: Environm
268268
const controller = new AbortController();
269269
checkController.current = controller;
270270
const timeout = setTimeout(() => controller.abort(), 20_000);
271-
try {
272-
const targetVersion = await findEnvironmentUpdate(
273-
config.environment.serverVersion,
274-
controller.signal,
275-
);
276-
setRelease({
277-
fromVersion: config.environment.serverVersion,
278-
targetVersion,
279-
});
280-
} finally {
271+
const fromVersion = config.environment.serverVersion;
272+
const targetVersion = await findEnvironmentUpdate(
273+
fromVersion,
274+
controller.signal,
275+
).finally(() => {
281276
clearTimeout(timeout);
282277
checkController.current = null;
283-
}
278+
});
279+
setRelease({ fromVersion, targetVersion });
284280
});
285281
}}
286282
/>

‎apps/mobile/src/features/settings/SettingsEnvironmentsRouteScreen.tsx‎

Lines changed: 33 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useNavigation } from "@react-navigation/native";
33
import { useAtomValue } from "@effect/atom-react";
44
import { managedRelaySessionAtom } from "@t3tools/client-runtime/relay";
55
import type { EnvironmentId } from "@t3tools/contracts";
6-
import { useCallback, useRef, useState } from "react";
6+
import { useRef, useState } from "react";
77
import { Platform, RefreshControl } from "react-native";
88
import { useSafeAreaInsets } from "react-native-safe-area-context";
99

@@ -59,49 +59,40 @@ export function SettingsEnvironmentsRouteScreen() {
5959
if (!relaySession || cloudRefreshPendingRef.current) return;
6060
cloudRefreshPendingRef.current = true;
6161
setIsRefreshingCloud(true);
62-
try {
63-
await refreshRelayEnvironments();
64-
} finally {
65-
cloudRefreshPendingRef.current = false;
66-
setIsRefreshingCloud(false);
67-
}
62+
await refreshRelayEnvironments();
63+
cloudRefreshPendingRef.current = false;
64+
setIsRefreshingCloud(false);
6865
}
6966

70-
const openEnvironment = useCallback(
71-
(environmentId: EnvironmentId) => {
72-
navigation.navigate("SettingsSheet", {
73-
screen: "SettingsContent",
74-
params: { screen: "SettingsEnvironmentDetail", params: { environmentId } },
75-
});
76-
},
77-
[navigation],
78-
);
79-
const handleUpdateEnvironment = useCallback(
80-
(
81-
environmentId: EnvironmentId,
82-
updates: { readonly label: string; readonly displayUrl: string },
83-
) => {
84-
if (!SHOWCASE_ENABLED) return onUpdateEnvironment(environmentId, updates);
85-
const actualEnvironment = environmentSections.localEnvironments.find(
86-
(environment) => environment.environmentId === environmentId,
87-
);
88-
const presentedEnvironment = localEnvironments.find(
89-
(environment) => environment.environmentId === environmentId,
90-
);
91-
return onUpdateEnvironment(environmentId, {
92-
...updates,
93-
displayUrl:
94-
actualEnvironment && presentedEnvironment
95-
? resolveShowcaseEnvironmentUpdateDisplayUrl({
96-
actualDisplayUrl: actualEnvironment.displayUrl,
97-
presentedDisplayUrl: presentedEnvironment.displayUrl,
98-
submittedDisplayUrl: updates.displayUrl,
99-
})
100-
: updates.displayUrl,
101-
});
102-
},
103-
[environmentSections.localEnvironments, localEnvironments, onUpdateEnvironment],
104-
);
67+
const openEnvironment = (environmentId: EnvironmentId) => {
68+
navigation.navigate("SettingsSheet", {
69+
screen: "SettingsContent",
70+
params: { screen: "SettingsEnvironmentDetail", params: { environmentId } },
71+
});
72+
};
73+
const handleUpdateEnvironment = (
74+
environmentId: EnvironmentId,
75+
updates: { readonly label: string; readonly displayUrl: string },
76+
) => {
77+
if (!SHOWCASE_ENABLED) return onUpdateEnvironment(environmentId, updates);
78+
const actualEnvironment = environmentSections.localEnvironments.find(
79+
(environment) => environment.environmentId === environmentId,
80+
);
81+
const presentedEnvironment = localEnvironments.find(
82+
(environment) => environment.environmentId === environmentId,
83+
);
84+
return onUpdateEnvironment(environmentId, {
85+
...updates,
86+
displayUrl:
87+
actualEnvironment && presentedEnvironment
88+
? resolveShowcaseEnvironmentUpdateDisplayUrl({
89+
actualDisplayUrl: actualEnvironment.displayUrl,
90+
presentedDisplayUrl: presentedEnvironment.displayUrl,
91+
submittedDisplayUrl: updates.displayUrl,
92+
})
93+
: updates.displayUrl,
94+
});
95+
};
10596

10697
return (
10798
<SettingsScreen

0 commit comments

Comments
 (0)