mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-19 09:13:57 +00:00
feat: use main-loop to watch seeding list
This commit is contained in:
@@ -98,6 +98,17 @@ export class DownloadManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static async watchSeedingList() {
|
||||
const seedingList = await PythonInstance.getSeedingList();
|
||||
|
||||
if (seedingList) {
|
||||
WindowManager.mainWindow?.webContents.send(
|
||||
"on-seeding-list",
|
||||
JSON.parse(JSON.stringify(seedingList))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
static async pauseDownload() {
|
||||
if (this.currentDownloader === Downloader.Torrent) {
|
||||
await PythonInstance.pauseDownload();
|
||||
|
||||
@@ -60,14 +60,15 @@ export class PythonInstance {
|
||||
);
|
||||
}
|
||||
|
||||
public static async getStatus() {
|
||||
if (this.downloadingGameId === -1) return null;
|
||||
|
||||
public static async getSeedingList() {
|
||||
const response = await this.rpc.get<LibtorrentPayload | null>("/status");
|
||||
|
||||
if (response.data === null) return null;
|
||||
return response.data?.seeding || [];
|
||||
}
|
||||
|
||||
console.log(response.data);
|
||||
public static async getStatus() {
|
||||
const response = await this.rpc.get<LibtorrentPayload | null>("/status");
|
||||
if (response.data?.downloading === null) return null;
|
||||
|
||||
try {
|
||||
const {
|
||||
@@ -80,7 +81,7 @@ export class PythonInstance {
|
||||
folderName,
|
||||
status,
|
||||
gameId,
|
||||
} = response.data;
|
||||
} = response.data?.downloading!;
|
||||
|
||||
this.downloadingGameId = gameId;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ export enum LibtorrentStatus {
|
||||
Seeding = 5,
|
||||
}
|
||||
|
||||
export interface LibtorrentPayload {
|
||||
export interface LibtorrentGamePayload {
|
||||
progress: number;
|
||||
numPeers: number;
|
||||
numSeeds: number;
|
||||
@@ -32,6 +32,23 @@ export interface LibtorrentPayload {
|
||||
gameId: number;
|
||||
}
|
||||
|
||||
export interface LibtorrentPayload {
|
||||
downloading?: LibtorrentGamePayload;
|
||||
seeding: LibtorrentGamePayload[];
|
||||
}
|
||||
|
||||
export interface LibtorrentSeedingPayload {
|
||||
progress: number;
|
||||
numPeers: number;
|
||||
numSeeds: number;
|
||||
uploadSpeed: number;
|
||||
// isCheckingFiles: boolean;
|
||||
fileSize: number;
|
||||
folderName: string;
|
||||
status: LibtorrentStatus;
|
||||
gameId: number;
|
||||
}
|
||||
|
||||
export interface ProcessPayload {
|
||||
exe: string;
|
||||
pid: number;
|
||||
|
||||
@@ -10,6 +10,7 @@ export const startMainLoop = async () => {
|
||||
watchProcesses(),
|
||||
DownloadManager.watchDownloads(),
|
||||
AchievementWatcherManager.watchAchievements(),
|
||||
DownloadManager.watchSeedingList(),
|
||||
]);
|
||||
|
||||
await sleep(1500);
|
||||
|
||||
Reference in New Issue
Block a user