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",
"no-async-promise-executor": "off",
"prettier/prettier": [
"error",
{

View File

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

View File

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