fix: removing async promise

This commit is contained in:
Chubby Granny Chaser
2025-03-31 01:01:44 +01:00
parent e6fde48dbd
commit 73f4b0e869
3 changed files with 11 additions and 6 deletions

View File

@@ -19,7 +19,6 @@ module.exports = {
}, },
], ],
"@typescript-eslint/no-explicit-any": "warn", "@typescript-eslint/no-explicit-any": "warn",
"no-async-promise-executor": "off",
"prettier/prettier": [ "prettier/prettier": [
"error", "error",
{ {

View File

@@ -5,7 +5,7 @@ const createDownloadSource = async (
_event: Electron.IpcMainInvokeEvent, _event: Electron.IpcMainInvokeEvent,
url: string url: string
) => { ) => {
return HydraApi.post("/profile/download-sources", { await HydraApi.post("/profile/download-sources", {
url, url,
}); });
}; };

View File

@@ -31,6 +31,7 @@ import { HydraCloudModal } from "./pages/shared-modals/hydra-cloud/hydra-cloud-m
import { injectCustomCss } from "./helpers"; import { injectCustomCss } from "./helpers";
import "./app.scss"; import "./app.scss";
import { DownloadSource } from "@types";
export interface AppProps { export interface AppProps {
children: React.ReactNode; children: React.ReactNode;
@@ -139,12 +140,15 @@ export function App() {
const syncDownloadSources = useCallback(async () => { const syncDownloadSources = useCallback(async () => {
const downloadSources = await window.electron.getDownloadSources(); const downloadSources = await window.electron.getDownloadSources();
const existingDownloadSources: DownloadSource[] =
await downloadSourcesTable.toArray();
await Promise.allSettled( await Promise.allSettled(
downloadSources.map(async (source) => { downloadSources.map(async (source) => {
return new Promise(async (resolve) => { return new Promise((resolve) => {
const existingDownloadSource = await downloadSourcesTable const existingDownloadSource = existingDownloadSources.find(
.where({ url: source.url }) (downloadSource) => downloadSource.url === source.url
.first(); );
if (!existingDownloadSource) { if (!existingDownloadSource) {
const channel = new BroadcastChannel( const channel = new BroadcastChannel(
@@ -160,6 +164,8 @@ export function App() {
resolve(true); resolve(true);
channel.close(); channel.close();
}; };
} else {
resolve(true);
} }
}); });
}) })