This commit is contained in:
parent
208ab8042e
commit
ad6eaad5d2
4 changed files with 83 additions and 62 deletions
|
|
@ -95,19 +95,18 @@ async function storageRemoveCritical(key) {
|
|||
async function hydrateDesktopStorage() {
|
||||
if (!window.electronAPI?.storageGet) return;
|
||||
for (const key of PERSISTED_STORAGE_KEYS) {
|
||||
const localVal = localStorage.getItem(key);
|
||||
if (localVal !== null) {
|
||||
try {
|
||||
await window.electronAPI.storageSet(key, localVal);
|
||||
} catch (err) {
|
||||
console.warn("Failed to backfill storage key", key, err);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
// IPC file store (renderer-storage.json) is the source of truth —
|
||||
// it always survives restarts, unlike localStorage on file:// URLs.
|
||||
const val = await window.electronAPI.storageGet(key);
|
||||
if (typeof val === "string") {
|
||||
localStorage.setItem(key, val);
|
||||
} else {
|
||||
// IPC store is empty; backfill from localStorage if available
|
||||
const localVal = localStorage.getItem(key);
|
||||
if (localVal !== null) {
|
||||
await window.electronAPI.storageSet(key, localVal);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn("Failed to hydrate storage key", key, err);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue