MCPcopy
hub / github.com/codedogQBY/ReadAny / LANSyncDialog

Function LANSyncDialog

packages/app/src/components/settings/LANSyncDialog.tsx:23–383  ·  view source on GitHub ↗
({ open, onClose, mode }: LANSyncDialogProps)

Source from the content-addressed store, hash-verified

21}
22
23export function LANSyncDialog({ open, onClose, mode }: LANSyncDialogProps) {
24 const { t } = useTranslation();
25 const { syncWithBackend } = useSyncStore();
26
27 const isManualIPError = useCallback((message: string): boolean => {
28 return (
29 message.includes("Could not determine local IP address") ||
30 message.includes("Failed to get local IP") ||
31 message.includes("Cannot auto-detect IP address")
32 );
33 }, []);
34
35 const normalizeServerError = useCallback(
36 (message: string): string => {
37 if (message.includes("Tauri desktop runtime is required")) {
38 return t("settings.syncLANTauriRequired");
39 }
40 return message;
41 },
42 [t],
43 );
44
45 // Server state
46 const [serverStatus, setServerStatus] = useState<LANServerStatus>("idle");
47 const [qrData, setQRData] = useState<LANQRData | null>(null);
48 const [server, setServer] = useState<ReturnType<typeof createLANServer> | null>(null);
49
50 // Client state
51 const [connectionState, setConnectionState] = useState<LANConnectionState>("idle");
52 const [manualIP, setManualIP] = useState("");
53 const [manualPort, setManualPort] = useState("");
54 const [manualPairCode, setManualPairCode] = useState("");
55
56 // Manual IP for server (when auto-detection fails)
57 const [showManualIPInput, setShowManualIPInput] = useState(false);
58 const [manualServerIP, setManualServerIP] = useState("");
59
60 const [error, setError] = useState("");
61
62 const confirmLanImport = useCallback(() => {
63 return window.confirm(
64 t(
65 "settings.syncLANImportWarning",
66 "This will overwrite this device's database, books, and covers with the server device data. Use it for migration, not two-way merge.",
67 ),
68 );
69 }, [t]);
70
71 // Server mode: start/stop server
72 const handleStartServer = useCallback(async () => {
73 setError("");
74 setServerStatus("starting");
75 setShowManualIPInput(false);
76
77 try {
78 const deviceName = `ReadAny Desktop`;
79
80 const newServer = createLANServer({

Callers

nothing calls this directly

Calls 7

createLANServerFunction · 0.90
createLANBackendFunction · 0.90
getQRDataMethod · 0.80
setManualIPMethod · 0.80
stopMethod · 0.65
testConnectionMethod · 0.65
startMethod · 0.45

Tested by

no test coverage detected