From ccfed89d46ec1ab5c14b8969dc68c68f2dcd3802 Mon Sep 17 00:00:00 2001 From: davidweb3-ctrl Date: Sat, 14 Mar 2026 09:11:14 +0000 Subject: [PATCH] fix(settings-sync): add confirmation dialog before import Adds a confirmation step before applying imported settings to prevent accidental overwrites of sync-managed local state. - Added confirmImport state to track pending import - Added pendingImport state to store file content - Shows warning with Yes/No confirmation before import - Cancel option discards the pending import Fixes PlatformNetwork/bounty-challenge#27667 --- src/components/settings/SettingsSyncPanel.tsx | 111 +++++++++++++----- 1 file changed, 83 insertions(+), 28 deletions(-) diff --git a/src/components/settings/SettingsSyncPanel.tsx b/src/components/settings/SettingsSyncPanel.tsx index 906c5f25..e7105389 100644 --- a/src/components/settings/SettingsSyncPanel.tsx +++ b/src/components/settings/SettingsSyncPanel.tsx @@ -719,6 +719,8 @@ function ImportExportSection() { const [importing, setImporting] = createSignal(false); const [exporting, setExporting] = createSignal(false); const [importError, setImportError] = createSignal(null); + const [confirmImport, setConfirmImport] = createSignal(false); + const [pendingImport, setPendingImport] = createSignal(null); let fileInputRef: HTMLInputElement | undefined; @@ -749,20 +751,39 @@ function ImportExportSection() { const file = input.files?.[0]; if (!file) return; - setImporting(true); setImportError(null); try { const text = await file.text(); - await importSettings(text); + setPendingImport(text); + setConfirmImport(true); } catch (e) { setImportError(e instanceof Error ? e.message : String(e)); } finally { - setImporting(false); input.value = ""; } }; + const handleConfirmImport = async () => { + if (!pendingImport()) return; + + setImporting(true); + try { + await importSettings(pendingImport()!); + setConfirmImport(false); + setPendingImport(null); + } catch (e) { + setImportError(e instanceof Error ? e.message : String(e)); + } finally { + setImporting(false); + } + }; + + const handleCancelImport = () => { + setConfirmImport(false); + setPendingImport(null); + }; + return (
@@ -776,31 +797,65 @@ function ImportExportSection() { -
- - - -
+ + + + +
+ } + > +
+
+
+ Confirm Import +

+ This will overwrite your current sync-managed settings with the imported backup. + This action cannot be undone. +

+
+
+
+ + +
+
+
);