From 44b711f674da89517f0e182a7a813cbcd0a91206 Mon Sep 17 00:00:00 2001 From: Chubby Granny Chaser Date: Sat, 12 Apr 2025 18:47:33 +0100 Subject: [PATCH] fix: fixing download sources initial sync --- src/renderer/src/app.tsx | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/renderer/src/app.tsx b/src/renderer/src/app.tsx index f9bd645e..d10f48cf 100644 --- a/src/renderer/src/app.tsx +++ b/src/renderer/src/app.tsx @@ -224,18 +224,28 @@ export function App() { const downloadSources = await downloadSourcesTable.toArray(); - downloadSources - .filter((source) => !source.fingerprint) - .forEach(async (downloadSource) => { - const { fingerprint } = await window.electron.putDownloadSource( - downloadSource.objectIds - ); + await Promise.all( + downloadSources + .filter((source) => !source.fingerprint) + .map(async (downloadSource) => { + const { fingerprint } = await window.electron.putDownloadSource( + downloadSource.objectIds + ); - downloadSourcesTable.update(downloadSource.id, { fingerprint }); - }); + return downloadSourcesTable.update(downloadSource.id, { + fingerprint, + }); + }) + ); + + channel.close(); }; downloadSourcesWorker.postMessage(["SYNC_DOWNLOAD_SOURCES", id]); + + return () => { + channel.close(); + }; }, [updateRepacks]); useEffect(() => {