From 73f4b0e8698271fddb20a1ebbd60252e23bef9e4 Mon Sep 17 00:00:00 2001 From: Chubby Granny Chaser Date: Mon, 31 Mar 2025 01:01:44 +0100 Subject: [PATCH] fix: removing async promise --- .eslintrc.cjs | 1 - .../download-sources/create-download-source.ts | 2 +- src/renderer/src/app.tsx | 14 ++++++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index f76a27a1..6da066af 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -19,7 +19,6 @@ module.exports = { }, ], "@typescript-eslint/no-explicit-any": "warn", - "no-async-promise-executor": "off", "prettier/prettier": [ "error", { diff --git a/src/main/events/download-sources/create-download-source.ts b/src/main/events/download-sources/create-download-source.ts index 82b5dd4d..bf5d3c18 100644 --- a/src/main/events/download-sources/create-download-source.ts +++ b/src/main/events/download-sources/create-download-source.ts @@ -5,7 +5,7 @@ const createDownloadSource = async ( _event: Electron.IpcMainInvokeEvent, url: string ) => { - return HydraApi.post("/profile/download-sources", { + await HydraApi.post("/profile/download-sources", { url, }); }; diff --git a/src/renderer/src/app.tsx b/src/renderer/src/app.tsx index 9d0b137e..67311ded 100644 --- a/src/renderer/src/app.tsx +++ b/src/renderer/src/app.tsx @@ -31,6 +31,7 @@ import { HydraCloudModal } from "./pages/shared-modals/hydra-cloud/hydra-cloud-m import { injectCustomCss } from "./helpers"; import "./app.scss"; +import { DownloadSource } from "@types"; export interface AppProps { children: React.ReactNode; @@ -139,12 +140,15 @@ export function App() { const syncDownloadSources = useCallback(async () => { const downloadSources = await window.electron.getDownloadSources(); + const existingDownloadSources: DownloadSource[] = + await downloadSourcesTable.toArray(); + await Promise.allSettled( downloadSources.map(async (source) => { - return new Promise(async (resolve) => { - const existingDownloadSource = await downloadSourcesTable - .where({ url: source.url }) - .first(); + return new Promise((resolve) => { + const existingDownloadSource = existingDownloadSources.find( + (downloadSource) => downloadSource.url === source.url + ); if (!existingDownloadSource) { const channel = new BroadcastChannel( @@ -160,6 +164,8 @@ export function App() { resolve(true); channel.close(); }; + } else { + resolve(true); } }); })