From 2a90faeb423a4aba858c778f13a9d853de128ee5 Mon Sep 17 00:00:00 2001 From: Chubby Granny Chaser Date: Mon, 27 Oct 2025 01:42:02 +0000 Subject: [PATCH] fix: persisting is remote --- .../events/download-sources/sync-download-sources.ts | 11 ++++++++--- src/renderer/src/declaration.d.ts | 2 +- .../src/pages/settings/settings-download-sources.tsx | 5 +++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/events/download-sources/sync-download-sources.ts b/src/main/events/download-sources/sync-download-sources.ts index 987ad1c1..68a6be3f 100644 --- a/src/main/events/download-sources/sync-download-sources.ts +++ b/src/main/events/download-sources/sync-download-sources.ts @@ -15,10 +15,15 @@ const syncDownloadSources = async (_event: Electron.IpcMainInvokeEvent) => { ); for (const downloadSource of response) { - await downloadSourcesSublevel.put(downloadSource.id, downloadSource); - } + const existingDownloadSource = downloadSources.find( + (source) => source.id === downloadSource.id + ); - return response; + await downloadSourcesSublevel.put(downloadSource.id, { + ...existingDownloadSource, + ...downloadSource, + }); + } }; registerEvent("syncDownloadSources", syncDownloadSources); diff --git a/src/renderer/src/declaration.d.ts b/src/renderer/src/declaration.d.ts index 4e004e2b..fa4ab3d6 100644 --- a/src/renderer/src/declaration.d.ts +++ b/src/renderer/src/declaration.d.ts @@ -213,7 +213,7 @@ declare global { downloadSourceId?: string ) => Promise; getDownloadSources: () => Promise; - syncDownloadSources: () => Promise; + syncDownloadSources: () => Promise; /* Hardware */ getDiskFreeSpace: (path: string) => Promise; diff --git a/src/renderer/src/pages/settings/settings-download-sources.tsx b/src/renderer/src/pages/settings/settings-download-sources.tsx index 52d3bd97..08670145 100644 --- a/src/renderer/src/pages/settings/settings-download-sources.tsx +++ b/src/renderer/src/pages/settings/settings-download-sources.tsx @@ -101,8 +101,9 @@ export function SettingsDownloadSources() { const syncDownloadSources = async () => { setIsSyncingDownloadSources(true); try { - const sources = await window.electron.syncDownloadSources(); - setDownloadSources(sources); + await window.electron.syncDownloadSources(); + const sources = await window.electron.getDownloadSources(); + setDownloadSources(sources as DownloadSource[]); showSuccessToast(t("download_sources_synced_successfully")); } finally {