feat(desktop): optional wipe-on-close (Settings -> Sicherheit)

This commit is contained in:
byGalax
2026-05-16 17:17:59 +02:00
parent 88345420e0
commit 9de2c368bf
8 changed files with 119 additions and 1 deletions
+13
View File
@@ -21,6 +21,7 @@ import { useTranslation } from 'react-i18next';
import { ensureInstallId } from '../lib/installId';
import { wipeLocalState } from '../lib/memoryWipe';
import { isWipeOnCloseEnabled } from '../lib/memoryWipeSettings';
import { setSecretStoreUser } from '../lib/secretStore';
import { supabase } from '../lib/supabase';
import { cachedUserKey, ensureLegacyMigrated } from '../lib/userIdentity';
@@ -195,6 +196,18 @@ export function AuthProvider({ children }: { children: ReactNode }) {
void registerWebPush(installId);
}, [session]);
// Wipe-on-close: register a handler the main process pings on `before-quit`
// when the user has enabled the Settings → Sicherheit toggle. No-op outside
// Electron (web build has no preload bridge) or when the toggle is off.
useEffect(() => {
if (typeof window.electronAPI?.onWipeBeforeQuit !== 'function') return;
const unsub = window.electronAPI.onWipeBeforeQuit(async () => {
if (!isWipeOnCloseEnabled()) return;
await wipeLocalState(session?.user.id ?? null);
});
return unsub;
}, [session?.user.id]);
// Auto online/offline transition.
//
// - On mount with a session whose last persisted state is `offline`, flip