mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
add log + use allSettled
This commit is contained in:
@@ -3,6 +3,7 @@ import { UtilsService } from "../services/utils.service";
|
||||
import { IpcRequest } from "shared/models/ipc";
|
||||
import { SearchParams } from "shared/models/maps/beat-saver.model";
|
||||
import { BeatSaverService } from "../services/thrid-party/beat-saver/beat-saver.service";
|
||||
import log from "electron-log";
|
||||
|
||||
ipcMain.on("bsv-search-map", async (event, request: IpcRequest<SearchParams>) => {
|
||||
const utlis = UtilsService.getInstance();
|
||||
@@ -22,6 +23,7 @@ ipcMain.on("bsv-get-map-details-from-hashs", async (event, request: IpcRequest<s
|
||||
bsvService.getMapDetailsFromHashs(request.args).then(maps => {
|
||||
utlis.ipcSend(request.responceChannel, {success: true, data: maps});
|
||||
}).catch(e => {
|
||||
log.error(e);
|
||||
utlis.ipcSend(request.responceChannel, {success: false, error: e});
|
||||
})
|
||||
});
|
||||
|
||||
@@ -135,8 +135,6 @@ export class LocalMapsManagerService {
|
||||
|
||||
return new Observable<BsmLocalMapsProgress>(observer => {
|
||||
(async () => {
|
||||
console.time()
|
||||
|
||||
const levelsFolder = await this.getMapsFolderPath(version);
|
||||
|
||||
const levelsPaths = (await this.utils.pathExist(levelsFolder)) ? this.utils.listDirsInDir(levelsFolder, true) : [];
|
||||
@@ -151,14 +149,18 @@ export class LocalMapsManagerService {
|
||||
return mapInfo;
|
||||
});
|
||||
|
||||
const mapsInfo = (await Promise.all(promises)).filter(info => info);
|
||||
const mapsInfo = (await Promise.allSettled(promises)).reduce((acc, mapInfo) => {
|
||||
if(mapInfo.status === "fulfilled" && mapInfo.value){
|
||||
acc.push(mapInfo.value);
|
||||
}
|
||||
return acc;
|
||||
} ,[] as BsmLocalMap[]);
|
||||
|
||||
progression.maps = mapsInfo;
|
||||
|
||||
observer.next(progression);
|
||||
|
||||
observer.complete();
|
||||
|
||||
console.timeEnd();
|
||||
})();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -47,7 +47,6 @@ export class IpcService {
|
||||
observable.subscribe(data => {
|
||||
this.send(channel, window, data);
|
||||
}, error => {
|
||||
console.log("LAAAA 2", error);
|
||||
this.send(this.getErrorChannel(channel), window, error);
|
||||
}, () => {
|
||||
this.send(this.getCompleteChannel(channel), window);
|
||||
|
||||
@@ -32,7 +32,7 @@ export class BeatSaverService {
|
||||
return res;
|
||||
}, [] as BsvMapDetail[]);
|
||||
|
||||
await Promise.all(chunkHash.map(async hashs => {
|
||||
await Promise.allSettled(chunkHash.map(async hashs => {
|
||||
const res = await this.bsaverApi.getMapsDetailsByHashs(hashs);
|
||||
|
||||
if(res.status === 200){
|
||||
|
||||
@@ -17,8 +17,8 @@ export class BeatSaverService {
|
||||
}
|
||||
|
||||
public async getMapDetailsFromHashs(hashs: string[]): Promise<BsvMapDetail[]>{
|
||||
//const res = await this.ipc.send<BsvMapDetail[], string[]>("bsv-get-map-details-from-hashs", {args: hashs});
|
||||
return [];
|
||||
const res = await this.ipc.send<BsvMapDetail[], string[]>("bsv-get-map-details-from-hashs", {args: hashs});
|
||||
return res.data ?? [];
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user