fix(app): improve host removal flow
This commit is contained in:
@@ -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}?`,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user