refactor: Update import paths and improve async function in get-magnet-health

This commit is contained in:
ChristoferMendes 2024-05-12 21:16:15 -03:00
parent 23ab98294a
commit 0333282915
3 changed files with 8 additions and 6 deletions

View file

@ -1,5 +1,5 @@
import { webTorrentData } from "@main/services/web-torrent-health"
import { registerEvent } from "../register-event"
import { webTorrentData } from "@main/services/web-torrent-data"
import { registerEvent } from "../../register-event"
const getMagnetHealth = async (_event: Electron.IpcMainInvokeEvent, magnet: string) => {
return webTorrentData.getSeedersAndPeers(magnet)

View file

@ -7,6 +7,7 @@ import "./catalogue/get-games";
import "./catalogue/get-how-long-to-beat";
import "./catalogue/get-random-game";
import "./catalogue/search-games";
import "./catalogue/repacks/get-magnet-health"
import "./hardware/get-disk-free-space";
import "./library/add-game-to-library";
import "./library/close-game";
@ -27,7 +28,6 @@ import "./torrenting/start-game-download";
import "./user-preferences/get-user-preferences";
import "./user-preferences/update-user-preferences";
import "./user-preferences/auto-launch";
import "./repacks/get-magnet-health"
ipcMain.handle("ping", () => "pong");
ipcMain.handle("getVersion", () => app.getVersion());

View file

@ -10,10 +10,12 @@ export const webTorrentData = {
return new Promise((resolve, reject) => {
WebTorrentHealth(magnet, (err: Error, data: WebTorrentHealthData) => {
if (err) {
reject(err);
} else {
resolve(data);
return reject(err);
}
const { peers, seeds } = data;
return resolve({ peers, seeders: seeds });
});
});
},