The best way to control Claude Code, Codex and more from any computer or phone

main
ts 22 lines 993 Bytes
Raw
1 import { requireNativeModule } from "expo";
2 import { useEffect, useMemo, useState } from "react";
3 import { AppState, Platform } from "react-native";
4 import { createMessageTimeFormatter } from "./messageTimestamp";
5
6 function systemUses24HourClock() {
7 if (Platform.OS !== "android") return undefined;
8 return requireNativeModule<{ is24HourFormat(): boolean }>("T3NativeControls").is24HourFormat();
9 }
10
11 export function useMessageTimeFormatter() {
12 const [is24Hour, setIs24Hour] = useState(systemUses24HourClock);
13 // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- Refresh the native clock preference when Android returns to the foreground.
14 useEffect(() => {
15 if (Platform.OS !== "android") return;
16 const subscription = AppState.addEventListener("change", (state) => {
17 if (state === "active") setIs24Hour(systemUses24HourClock());
18 });
19 return () => subscription.remove();
20 }, []);
21 return useMemo(() => createMessageTimeFormatter(is24Hour), [is24Hour]);
22 }