fix(app): improve host removal flow

This commit is contained in:
Mohamed Boudra
2026-01-22 08:52:30 +07:00
parent 42fb56890b
commit ca8d09434b
3 changed files with 102 additions and 3 deletions
+15
View File
@@ -545,6 +545,21 @@ export default function SettingsScreen() {
const handleRemoveDaemon = useCallback(
(profile: DaemonProfile) => {
if (Platform.OS === "web") {
const hasBrowserConfirm =
typeof globalThis !== "undefined" &&
typeof (globalThis as any).confirm === "function";
const confirmed = hasBrowserConfirm ? (globalThis as any).confirm(`Remove ${profile.label}?`) : true;
if (!confirmed) return;
void removeDaemon(profile.id).catch((error) => {
console.error("[Settings] Failed to remove daemon", error);
Alert.alert("Error", "Unable to remove host");
});
return;
}
Alert.alert(
"Remove Host",
`Remove ${profile.label}?`,
+8 -3
View File
@@ -19,9 +19,14 @@ async function getTauriWindow() {
}
try {
// @metro-ignore tells Metro to skip bundling this import
// It will be resolved at runtime in Tauri's WebView
const { getCurrentWindow } = await import(/* @metro-ignore */ "@tauri-apps/api/window");
// Avoid emitting `import()` syntax into the Hermes bundle (it fails to parse),
// while still loading the Tauri module at runtime in the WebView.
const dynamicImport = new Function(
"moduleName",
"return import(moduleName)"
) as (moduleName: string) => Promise<any>;
const { getCurrentWindow } = await dynamicImport("@tauri-apps/api/window");
tauriWindow = getCurrentWindow();
return tauriWindow;
} catch {