fix: persisting is remote

This commit is contained in:
Chubby Granny Chaser
2025-10-27 01:42:02 +00:00
parent 87a57f7a37
commit 2a90faeb42
3 changed files with 12 additions and 6 deletions

View File

@@ -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);

View File

@@ -213,7 +213,7 @@ declare global {
downloadSourceId?: string
) => Promise<void>;
getDownloadSources: () => Promise<DownloadSource[]>;
syncDownloadSources: () => Promise<DownloadSource[]>;
syncDownloadSources: () => Promise<void>;
/* Hardware */
getDiskFreeSpace: (path: string) => Promise<DiskUsage>;

View File

@@ -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 {