mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
[chore-245] convert some "send" calls to "sendV2"
This commit is contained in:
@@ -6,35 +6,19 @@ import { IpcRequest } from "shared/models/ipc";
|
||||
import { Mod } from "shared/models/mods/mod.interface";
|
||||
import { InstallModsResult } from "shared/models/mods";
|
||||
import log from "electron-log";
|
||||
import { IpcService } from "../services/ipc.service";
|
||||
import { from } from "rxjs";
|
||||
|
||||
ipcMain.on("get-available-mods", (event, request: IpcRequest<BSVersion>) => {
|
||||
const utils = UtilsService.getInstance();
|
||||
const ipc = IpcService.getInstance();
|
||||
|
||||
ipc.on<BSVersion>("get-available-mods", (req, reply) => {
|
||||
const modsManager = BsModsManagerService.getInstance();
|
||||
|
||||
modsManager
|
||||
.getAvailableMods(request.args)
|
||||
.then(mods => {
|
||||
utils.ipcSend(request.responceChannel, { success: true, data: mods });
|
||||
})
|
||||
.catch(err => {
|
||||
utils.ipcSend(request.responceChannel, { success: false });
|
||||
log.error("ipc", "get-available-mods", err, request);
|
||||
});
|
||||
reply(from(modsManager.getAvailableMods(req.args)));
|
||||
});
|
||||
|
||||
ipcMain.on("get-installed-mods", (event, request: IpcRequest<BSVersion>) => {
|
||||
const utils = UtilsService.getInstance();
|
||||
ipc.on<BSVersion>("get-installed-mods", (req, reply) => {
|
||||
const modsManager = BsModsManagerService.getInstance();
|
||||
|
||||
modsManager
|
||||
.getInstalledMods(request.args)
|
||||
.then(mods => {
|
||||
utils.ipcSend(request.responceChannel, { success: true, data: mods });
|
||||
})
|
||||
.catch(err => {
|
||||
utils.ipcSend(request.responceChannel, { success: false });
|
||||
log.error("ipc", "get-installed-mods", err, request);
|
||||
});
|
||||
reply(from(modsManager.getInstalledMods(req.args)));
|
||||
});
|
||||
|
||||
ipcMain.on("install-mods", (event, request: IpcRequest<{ mods: Mod[]; version: BSVersion }>) => {
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
import { ipcMain } from "electron";
|
||||
import { BSVersion } from "shared/bs-version.interface";
|
||||
import { UtilsService } from "../services/utils.service";
|
||||
import { IpcRequest } from "shared/models/ipc";
|
||||
import { BSLocalVersionService } from "../services/bs-local-version.service";
|
||||
import { IpcService } from "../services/ipc.service";
|
||||
import { from } from "rxjs";
|
||||
|
||||
ipcMain.on("bs.uninstall", async (event, request: IpcRequest<BSVersion>) => {
|
||||
const ipc = IpcService.getInstance();
|
||||
|
||||
ipc.on<BSVersion>("bs.uninstall", (req, reply) => {
|
||||
const bsLocalVersionService = BSLocalVersionService.getInstance();
|
||||
const utilsService = UtilsService.getInstance();
|
||||
|
||||
if (!request.args) {
|
||||
utilsService.ipcSend(request.responceChannel, { success: false });
|
||||
}
|
||||
|
||||
const res = await bsLocalVersionService.deleteVersion(request.args);
|
||||
utilsService.ipcSend(request.responceChannel, { success: res });
|
||||
reply(from(bsLocalVersionService.deleteVersion(req.args)));
|
||||
});
|
||||
|
||||
@@ -2,6 +2,10 @@ import { ipcMain } from "electron";
|
||||
import { AutoUpdaterService } from "../services/auto-updater.service";
|
||||
import { IpcRequest } from "shared/models/ipc";
|
||||
import { UtilsService } from "../services/utils.service";
|
||||
import { IpcService } from "../services/ipc.service";
|
||||
import { from } from "rxjs";
|
||||
|
||||
const ipc = IpcService.getInstance();
|
||||
|
||||
ipcMain.on("download-update", async (event, request: IpcRequest<void>) => {
|
||||
const updaterService = AutoUpdaterService.getInstance();
|
||||
@@ -13,16 +17,11 @@ ipcMain.on("download-update", async (event, request: IpcRequest<void>) => {
|
||||
.catch(() => utilsService.ipcSend(request.responceChannel, { success: false }));
|
||||
});
|
||||
|
||||
ipcMain.on("check-update", async (event, request: IpcRequest<void>) => {
|
||||
ipc.on("check-update", (_, reply) => {
|
||||
const updaterService = AutoUpdaterService.getInstance();
|
||||
const utilsService = UtilsService.getInstance();
|
||||
|
||||
updaterService
|
||||
.isUpdateAvailable()
|
||||
.then(updateAvailable => {
|
||||
utilsService.ipcSend(request.responceChannel, { success: true, data: updateAvailable });
|
||||
})
|
||||
.catch(() => utilsService.ipcSend(request.responceChannel, { success: false }));
|
||||
reply(from(updaterService.isUpdateAvailable()));
|
||||
});
|
||||
|
||||
ipcMain.on("install-update", async (event, request: IpcRequest<void>) => {
|
||||
|
||||
@@ -5,17 +5,12 @@ import { SystemNotificationOptions } from "shared/models/notification/system-not
|
||||
import { NotificationService } from "../services/notification.service";
|
||||
import { SteamService } from "../services/steam.service";
|
||||
import { IpcService } from "../services/ipc.service";
|
||||
import { from } from "rxjs";
|
||||
import { from, of } from "rxjs";
|
||||
|
||||
// TODO IMPROVE WINDOW CONTROL BY USING WINDOW SERVICE
|
||||
|
||||
const ipc = IpcService.getInstance();
|
||||
|
||||
ipcMain.on("window.close", async () => {
|
||||
const utils = UtilsService.getInstance();
|
||||
utils.getMainWindows("index.html")?.close();
|
||||
});
|
||||
|
||||
ipcMain.on("window.maximize", async () => {
|
||||
const utils = UtilsService.getInstance();
|
||||
utils.getMainWindows("index.html")?.maximize();
|
||||
@@ -35,7 +30,7 @@ ipcMain.on("new-window", async (event, request: IpcRequest<string>) => {
|
||||
shell.openExternal(request.args);
|
||||
});
|
||||
|
||||
ipc.on("choose-folder", async (req: IpcRequest<string>, reply) => {
|
||||
ipc.on<string>("choose-folder", async (req, reply) => {
|
||||
reply(from(dialog.showOpenDialog({ properties: ["openDirectory"], defaultPath: req.args ?? "" })));
|
||||
});
|
||||
|
||||
@@ -54,8 +49,8 @@ ipcMain.on("save-file", async (event, request: IpcRequest<{ filename?: string; f
|
||||
});
|
||||
});
|
||||
|
||||
ipcMain.on("current-version", async (event, request: IpcRequest<void>) => {
|
||||
UtilsService.getInstance().ipcSend(request.responceChannel, { success: true, data: app.getVersion() });
|
||||
ipc.on("current-version", (_, reply) => {
|
||||
reply(of(app.getVersion()));
|
||||
});
|
||||
|
||||
ipcMain.on("open-logs", async (event, request: IpcRequest<void>) => {
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
import { ipcMain } from "electron";
|
||||
import { WindowManagerService } from "../services/window-manager.service";
|
||||
import { IpcRequest } from "shared/models/ipc";
|
||||
import { AppWindow } from "shared/models/window-manager/app-window.model";
|
||||
import { BSLauncherService } from "../services/bs-launcher.service";
|
||||
import { IpcService } from "../services/ipc.service";
|
||||
import { from } from "rxjs";
|
||||
import { from, of } from "rxjs";
|
||||
|
||||
const launcher = BSLauncherService.getInstance();
|
||||
const ipc = IpcService.getInstance();
|
||||
|
||||
ipcMain.on("open-window-then-close-all", async (event, request: IpcRequest<AppWindow>) => {
|
||||
ipc.on<AppWindow>("open-window-then-close-all", (req, reply) => {
|
||||
const windowManager = WindowManagerService.getInstance();
|
||||
|
||||
windowManager.openWindow(request.args).then(window => {
|
||||
windowManager.closeAllWindows(request.args);
|
||||
const res = windowManager.openWindow(req.args).then(() => {
|
||||
windowManager.closeAllWindows(req.args);
|
||||
});
|
||||
|
||||
reply(from(res));
|
||||
});
|
||||
|
||||
ipcMain.on("close-all-windows", async (event, request: IpcRequest<AppWindow>) => {
|
||||
ipc.on<AppWindow>("close-all-windows", async (req, reply) => {
|
||||
await launcher.restoreSteamVR();
|
||||
const windowManager = WindowManagerService.getInstance();
|
||||
windowManager.closeAllWindows(request.args);
|
||||
reply(of(windowManager.closeAllWindows(req.args)));
|
||||
});
|
||||
|
||||
ipcMain.on("close-windows", async (event, request: IpcRequest<AppWindow[]>) => {
|
||||
ipc.on<AppWindow[]>("close-windows", async (req, reply) => {
|
||||
await launcher.restoreSteamVR();
|
||||
const windowManager = WindowManagerService.getInstance();
|
||||
windowManager.close(...request.args);
|
||||
reply(of(windowManager.close(...req.args)));
|
||||
});
|
||||
|
||||
ipc.on<AppWindow>("open-window-or-focus", (req, reply) => {
|
||||
|
||||
Reference in New Issue
Block a user