clean code

This commit is contained in:
MathieuG-P
2022-07-17 19:47:07 +02:00
parent e203fb603d
commit 4fd3a1da2f
27 changed files with 137 additions and 158 deletions
+8 -8
View File
@@ -1,7 +1,7 @@
import { ipcMain } from 'electron';
import { BSVersion } from '../services/bs-version-manager.service';
import { BSVersion } from '../services/bs-version-lib.service';
import { BSInstallerService, DownloadEventType } from '../services/bs-installer.service';
import { IpcRequest } from '../../shared/models/ipc-models.model';
import { IpcRequest } from 'shared/models/ipc';
import { InstallationLocationService } from '../services/installation-location.service';
import { UtilsService } from '../services/utils.service';
@@ -25,9 +25,9 @@ export interface DownloadInfo {
ipcMain.on('bs-download.start', async (event, request: IpcRequest<DownloadInfo>) => {
BSInstallerService.getInstance().downloadBsVersion(request.args).then(res => {
UtilsService.getInstance().newIpcSenc(request.responceChannel, {success: true, data: res});
UtilsService.getInstance().ipcSend(request.responceChannel, {success: true, data: res});
}).catch(e => {
UtilsService.getInstance().newIpcSenc(request.responceChannel, {success: false, data: e});
UtilsService.getInstance().ipcSend(request.responceChannel, {success: false, data: e});
});
});
@@ -37,22 +37,22 @@ ipcMain.on(`bs-download.${"[2FA]" as DownloadEventType}`, async (event, args: Ip
ipcMain.on('bs-download.kill', async (event, request: IpcRequest<void>) => {
const res = await BSInstallerService.getInstance().killDownloadProcess();
if(request.responceChannel){ UtilsService.getInstance().newIpcSenc(request.responceChannel, {success: res}); }
if(request.responceChannel){ UtilsService.getInstance().ipcSend(request.responceChannel, {success: res}); }
});
ipcMain.on('bs-download.installation-folder', async (event, request: IpcRequest<void>) => {
const installationFolder = InstallationLocationService.getInstance().installationDirectory;
UtilsService.getInstance().newIpcSenc(request.responceChannel, {success: true, data: installationFolder});
UtilsService.getInstance().ipcSend(request.responceChannel, {success: true, data: installationFolder});
});
ipcMain.on('bs-download.set-installation-folder', (event, request: IpcRequest<string>) => {
const installerService = InstallationLocationService.getInstance();
installerService.setInstallationDirectory(request.args).then(res => {
console.log("déplacement terminer");
UtilsService.getInstance().newIpcSenc(request.responceChannel, {success: true, data: res});
UtilsService.getInstance().ipcSend(request.responceChannel, {success: true, data: res});
}).catch(err => {
console.log(err);
UtilsService.getInstance().newIpcSenc(request.responceChannel, {success: false, error: {title: err, type: 'error'}});
UtilsService.getInstance().ipcSend(request.responceChannel, {success: false, error: {title: err, type: 'error'}});
});
})
+3 -3
View File
@@ -2,15 +2,15 @@ import { ipcMain } from 'electron';
import { UtilsService } from '../services/utils.service'
import { LauchOption } from "../../shared/models/launch-models.model";
import { BSLauncherService } from "../services/bs-launcher.service"
import { IpcRequest } from 'shared/models/ipc-models.model';
import { IpcRequest } from 'shared/models/ipc';
ipcMain.on('bs-launch.launch', (event, request: IpcRequest<LauchOption>) => {
const launcherService = BSLauncherService.getInstance();
const utilsService = UtilsService.getInstance();
launcherService.launch(request.args).then(res => {
utilsService.newIpcSenc(request.responceChannel, {success: true, data: res});
utilsService.ipcSend(request.responceChannel, {success: true, data: res});
}).catch(err => {
utilsService.newIpcSenc(request.responceChannel, {success: false, error: {title: err, type: 'error'}});
utilsService.ipcSend(request.responceChannel, {success: false, error: {title: err, type: 'error'}});
})
});
+4 -4
View File
@@ -1,7 +1,7 @@
import { ipcMain } from "electron";
import { BSVersion } from "main/services/bs-version-manager.service";
import { BSVersion } from "main/services/bs-version-lib.service";
import { UtilsService } from "../services/utils.service";
import { IpcRequest } from "shared/models/ipc-models.model";
import { IpcRequest } from "shared/models/ipc";
import { BSLocalVersionService } from "../services/bs-local-version.service";
ipcMain.on('bs.uninstall', async (event, request: IpcRequest<BSVersion>) => {
@@ -9,8 +9,8 @@ ipcMain.on('bs.uninstall', async (event, request: IpcRequest<BSVersion>) => {
const bsLocalVersionService = BSLocalVersionService.getInstance();
const utilsService = UtilsService.getInstance();
if(!request.args){ utilsService.newIpcSenc(request.responceChannel, {success: false}); }
if(!request.args){ utilsService.ipcSend(request.responceChannel, {success: false}); }
const res = await bsLocalVersionService.deleteVersion(request.args);
utilsService.newIpcSenc(request.responceChannel, {success: res});
utilsService.ipcSend(request.responceChannel, {success: res});
});
+10 -10
View File
@@ -1,33 +1,33 @@
import { ipcMain } from 'electron';
import { UtilsService } from '../services/utils.service';
import { BSVersionManagerService } from '../services/bs-version-manager.service'
import { BSVersion } from "main/services/bs-version-manager.service";
import { BSVersionLibService } from '../services/bs-version-lib.service'
import { BSVersion } from "main/services/bs-version-lib.service";
import path from 'path';
import { exec } from 'child_process';
import { SteamService } from '../services/steam.service';
import { BS_APP_ID } from '../constants';
import { IpcRequest } from 'shared/models/ipc-models.model';
import { IpcRequest } from 'shared/models/ipc';
import { BSLocalVersionService } from '../services/bs-local-version.service';
import { InstallationLocationService } from '../services/installation-location.service';
ipcMain.on('bs-version.get-version-dict', (event, req: IpcRequest<void>) => {
BSVersionManagerService.getInstance().getAvailableVersions().then(versions => {
UtilsService.getInstance().newIpcSenc(req.responceChannel, {success: true, data: versions});
BSVersionLibService.getInstance().getAvailableVersions().then(versions => {
UtilsService.getInstance().ipcSend(req.responceChannel, {success: true, data: versions});
}).catch(() => {
UtilsService.getInstance().newIpcSenc(req.responceChannel, {success: false});
UtilsService.getInstance().ipcSend(req.responceChannel, {success: false});
})
});
ipcMain.on('bs-version.installed-versions', async (event, req: IpcRequest<void>) => {
BSLocalVersionService.getInstance().getInstalledVersions().then(versions => {
UtilsService.getInstance().newIpcSenc(req.responceChannel, {success: true, data: versions});
UtilsService.getInstance().ipcSend(req.responceChannel, {success: true, data: versions});
}).catch(() => {
UtilsService.getInstance().newIpcSenc(req.responceChannel, {success: false});
UtilsService.getInstance().ipcSend(req.responceChannel, {success: false});
})
});
ipcMain.on("bs-version.open-folder", async (event, args: BSVersion) => {
ipcMain.on("bs-version.open-folder", async (event, req: IpcRequest<BSVersion>) => {
const locationService = InstallationLocationService.getInstance();
const versionFolder = args.steam ? await SteamService.getInstance().getGameFolder(BS_APP_ID, "Beat Saber") : path.join(locationService.versionsDirectory, args.BSVersion);
const versionFolder = req.args.steam ? await SteamService.getInstance().getGameFolder(BS_APP_ID, "Beat Saber") : path.join(locationService.versionsDirectory, req.args.BSVersion);
UtilsService.getInstance().folderExist(versionFolder) && exec(`start "" "${versionFolder}"`);
});
+2 -3
View File
@@ -1,8 +1,7 @@
import { ipcMain, shell, dialog } from 'electron';
import { UtilsService } from '../services/utils.service';
import { IpcRequest } from '../../shared/models/ipc-models.model';
import { IpcRequest } from 'shared/models/ipc';
import { getMainWindow } from '../main';
import { request } from 'http';
ipcMain.on('window.close', async () => {
getMainWindow()?.close();
@@ -26,7 +25,7 @@ ipcMain.on('new-window', async (event, request: IpcRequest<string>) => {
ipcMain.on('choose-folder', async (event, request: IpcRequest<void>) => {
dialog.showOpenDialog({properties: ['openDirectory']}).then(res => {
UtilsService.getInstance().newIpcSenc(request.responceChannel, {success: true, data: res});
UtilsService.getInstance().ipcSend(request.responceChannel, {success: true, data: res});
});
});
+5 -5
View File
@@ -1,6 +1,6 @@
import { BS_APP_ID, BS_DEPOT } from "../constants";
import path from "path";
import { BSVersion, BSVersionManagerService } from "./bs-version-manager.service";
import { BSVersion, BSVersionLibService } from "./bs-version-lib.service";
import { UtilsService } from "./utils.service";
import { ChildProcessWithoutNullStreams, spawn } from "child_process";
import log from "electron-log";
@@ -12,13 +12,13 @@ export class BSInstallerService{
private static instance: BSInstallerService;
private readonly utils: UtilsService;
private readonly bsVersionService: BSVersionManagerService;
private readonly bsVersionService: BSVersionLibService;
private readonly installLocationService: InstallationLocationService;
private downloadProcess: ChildProcessWithoutNullStreams;
private constructor(){
this.bsVersionService = BSVersionManagerService.getInstance();
this.bsVersionService = BSVersionLibService.getInstance();
this.utils = UtilsService.getInstance();
this.installLocationService = InstallationLocationService.getInstance();
}
@@ -34,7 +34,7 @@ export class BSInstallerService{
private sendDownloadEvent(event: DownloadEventType, data?: string|number, success: boolean = true): void{
if(typeof data === "string"){ data = data.replaceAll(/\[|\]/g, ""); }
this.utils.newIpcSenc(`bs-download.${event}`, { success: success, data: data });
this.utils.ipcSend(`bs-download.${event}`, { success: success, data: data });
}
public sendInputProcess(input: string){
@@ -57,7 +57,7 @@ export class BSInstallerService{
public async downloadBsVersion(downloadInfos: DownloadInfo): Promise<DownloadEvent>{
if(this.downloadProcess && !this.downloadProcess?.killed){ console.log("*** AlreadyDownloading ***"); return {type: "[AlreadyDownloading]"}; }
const bsVersion = this.bsVersionService.getVersionDetailFromVersionNumber(downloadInfos.bsVersion.BSVersion);
const bsVersion = this.bsVersionService.getVersionDetails(downloadInfos.bsVersion.BSVersion);
if(!bsVersion){ return {type: "[Error]"}; }
this.utils.createFolderIfNotExist(this.installLocationService.versionsDirectory);
+7 -7
View File
@@ -1,19 +1,19 @@
import path from "path";
import { BsLaunchResult, LauchOption } from "shared/models/launch-models.model";
import { BSInstallerService } from "./bs-installer.service";
import { BSVersion } from "./bs-version-manager.service";
import { BSVersion } from "./bs-version-lib.service";
import { UtilsService } from "./utils.service";
import { BS_EXECUTABLE, BS_APP_ID } from "../constants";
import { ChildProcessWithoutNullStreams, spawn } from "child_process";
import { SteamService } from "./steam.service";
import { InstallationLocationService } from "./installation-location.service";
export class BSLauncherService{
private static instance: BSLauncherService;
private readonly utilsService: UtilsService;
private readonly installerService: BSInstallerService;
private readonly steamService: SteamService;
private readonly installLocationService: InstallationLocationService;
private bsProcess: ChildProcessWithoutNullStreams;
@@ -24,8 +24,8 @@ export class BSLauncherService{
private constructor(){
this.utilsService = UtilsService.getInstance();
this.installerService = BSInstallerService.getInstance();
this.steamService = SteamService.getInstance();
this.installLocationService = InstallationLocationService.getInstance();
}
public isBsRunning(): boolean{
@@ -33,7 +33,7 @@ export class BSLauncherService{
}
public isExeExist(version: BSVersion): boolean{
const exePath = path.join(this.installerService.installationFolder, version.BSVersion, BS_EXECUTABLE);
const exePath = path.join(this.installLocationService.versionsDirectory, version.BSVersion, BS_EXECUTABLE);
return this.utilsService.pathExist(exePath);
}
@@ -42,7 +42,7 @@ export class BSLauncherService{
if(!this.isExeExist(launchOptions.version)){ return "EXE_NOT_FINDED"; }
if(this.isBsRunning()){ return "BS_ALREADY_RUNNING" }
const cwd = launchOptions.version.steam ? await this.steamService.getGameFolder(BS_APP_ID, "Beat Saber") : path.join(this.installerService.installationFolder, launchOptions.version.BSVersion);
const cwd = launchOptions.version.steam ? await this.steamService.getGameFolder(BS_APP_ID, "Beat Saber") : path.join(this.installLocationService.versionsDirectory, launchOptions.version.BSVersion);
const exePath = path.join(cwd, BS_EXECUTABLE);
const launchMods = [launchOptions.oculus && "-vrmode oculus", launchOptions.desktop && "fpfc", launchOptions.debug && "--verbose"];
@@ -50,7 +50,7 @@ export class BSLauncherService{
this.bsProcess.on('message', msg => { /** EMIT HERE **/ });
this.bsProcess.on('error', err => { /** EMIT HERE **/ });
this.bsProcess.on('exit', code => this.utilsService.newIpcSenc("bs-launch.exit", {data: code, success: true}));
this.bsProcess.on('exit', code => this.utilsService.ipcSend("bs-launch.exit", {data: code, success: true}));
return "LAUNCHED";
}
@@ -1,4 +1,4 @@
import { BSVersion, BSVersionManagerService } from "./bs-version-manager.service";
import { BSVersion, BSVersionLibService } from "./bs-version-lib.service";
import { InstallationLocationService } from "./installation-location.service";
import { SteamService } from "./steam.service";
import { UtilsService } from "./utils.service";
@@ -14,7 +14,7 @@ export class BSLocalVersionService{
private readonly installLocationService: InstallationLocationService;
private readonly utilsService: UtilsService;
private readonly steamService: SteamService;
private readonly remoteVersionService: BSVersionManagerService;
private readonly remoteVersionService: BSVersionLibService;
public static getInstance(): BSLocalVersionService{
if(!BSLocalVersionService.instance){ BSLocalVersionService.instance = new BSLocalVersionService(); }
@@ -25,7 +25,7 @@ export class BSLocalVersionService{
this.installLocationService = InstallationLocationService.getInstance();
this.utilsService = UtilsService.getInstance();
this.steamService = SteamService.getInstance();
this.remoteVersionService = BSVersionManagerService.getInstance();
this.remoteVersionService = BSVersionLibService.getInstance();
}
private async getVersionOfBSFolder(bsPath: string): Promise<string>{
@@ -53,7 +53,7 @@ export class BSLocalVersionService{
if(steamBsFolder && this.utilsService.pathExist(steamBsFolder)){
const steamBsVersion = await this.getVersionOfBSFolder(steamBsFolder);
if(steamBsVersion){
const steamVersionDetails = this.remoteVersionService.getVersionDetailFromVersionNumber(steamBsVersion);
const steamVersionDetails = this.remoteVersionService.getVersionDetails(steamBsVersion);
versions.push(steamVersionDetails ? {...steamVersionDetails, steam: true} : {BSVersion: steamBsVersion, steam: true});
}
}
@@ -63,7 +63,7 @@ export class BSLocalVersionService{
const folderInInstallation = this.utilsService.listDirsInDir(this.installLocationService.versionsDirectory);
folderInInstallation.forEach(f => {
const version = this.remoteVersionService.getVersionDetailFromVersionNumber(f);
const version = this.remoteVersionService.getVersionDetails(f);
versions.push(version);
})
return versions;
@@ -1,15 +1,14 @@
import { get } from 'https'
import { UtilsService } from './utils.service';
import path, { resolve } from 'path';
import { createReadStream, writeFileSync } from 'fs';
import { createInterface } from 'readline';
import path from 'path';
import { writeFileSync } from 'fs';
export class BSVersionManagerService{
export class BSVersionLibService{
private static readonly REMOTE_BS_VERSIONS_URL: string = "https://raw.githubusercontent.com/Zagrios/bs-manager/master/assets/jsons/bs-versions.json"
private static readonly VERSIONS_FILE: string = "bs-versions.json";
private readonly REMOTE_BS_VERSIONS_URL: string = "https://raw.githubusercontent.com/Zagrios/bs-manager/master/assets/jsons/bs-versions.json"
private readonly VERSIONS_FILE: string = "bs-versions.json";
private static instance: BSVersionManagerService;
private static instance: BSVersionLibService;
private utilsService: UtilsService;
@@ -20,15 +19,15 @@ export class BSVersionManagerService{
}
public static getInstance(): BSVersionManagerService{
if(!BSVersionManagerService.instance){ BSVersionManagerService.instance = new BSVersionManagerService(); }
return BSVersionManagerService.instance;
public static getInstance(): BSVersionLibService{
if(!BSVersionLibService.instance){ BSVersionLibService.instance = new BSVersionLibService(); }
return BSVersionLibService.instance;
}
private getRemoteVersions(): Promise<BSVersion[]>{
return new Promise<BSVersion[]>((resolve, reject) => {
let body = ''
get(BSVersionManagerService.REMOTE_BS_VERSIONS_URL, (res) => {
get(this.REMOTE_BS_VERSIONS_URL, (res) => {
res.on('data', chunk => body += chunk);
res.on('end', () => {
this.bsVersions = JSON.parse(body);
@@ -40,18 +39,17 @@ export class BSVersionManagerService{
}
private async getLocalVersions(): Promise<BSVersion[]>{
const localVersionsPath = path.join(this.utilsService.getAssestsJsonsPath(), BSVersionManagerService.VERSIONS_FILE);
const localVersionsPath = path.join(this.utilsService.getAssestsJsonsPath(), this.VERSIONS_FILE);
const rawVersion = (await this.utilsService.readFileAsync(localVersionsPath)).toString();
return JSON.parse(rawVersion);
}
private async updateLocalVersions(versions: BSVersion[]): Promise<void>{
const localVersionsPath = path.join(this.utilsService.getAssestsJsonsPath(), BSVersionManagerService.VERSIONS_FILE);
const localVersionsPath = path.join(this.utilsService.getAssestsJsonsPath(), this.VERSIONS_FILE);
writeFileSync(localVersionsPath, JSON.stringify(versions, null, "\t"), {encoding: 'utf-8', flag: 'w'});
};
public async loadBsVersions(): Promise<BSVersion[]>{
if(this.bsVersions && this.bsVersions.length){ return this.bsVersions; }
private async loadBsVersions(): Promise<BSVersion[]>{
const [localVersions, remoteVersions] = await Promise.all([
this.getLocalVersions(), this.getRemoteVersions()
]);
@@ -62,33 +60,14 @@ export class BSVersionManagerService{
}
public async getAvailableVersions(): Promise<BSVersion[]>{
if(this.bsVersions && this.bsVersions.length){ return this.bsVersions; }
const bsVersions = await this.loadBsVersions();
if(!bsVersions || !bsVersions.length){ return []; }
return bsVersions;
}
public async getVersionOfBSFolder(bsPath: string): Promise<string>{
const versionFilePath = path.join(bsPath, 'Beat Saber_Data', 'globalgamemanagers');
if(!this.utilsService.pathExist(versionFilePath)){ return null; }
const versionsAvailable = await this.getAvailableVersions();
return new Promise<string>(async (resolve, reject) => {
const readLine = createInterface({ input: createReadStream(versionFilePath) });
let findVersion: string = null;
readLine.on('line', (line) => {
for(const version of versionsAvailable){
if(line.includes(version.BSVersion)){ findVersion = version.BSVersion; readLine.close(); }
}
});
readLine.on('close', () => {
if(findVersion){ resolve(findVersion) }
resolve(findVersion);
});
})
}
public getVersionDetailFromVersionNumber(version: string): BSVersion{
public getVersionDetails(version: string): BSVersion{
return this.bsVersions.find(v => v.BSVersion === version);
}
+2 -6
View File
@@ -4,7 +4,7 @@ import { homedir } from "os";
import path from "path";
import { BrowserWindow } from "electron";
import { rm } from "fs/promises";
import { IpcResponse } from "shared/models/ipc-models.model";
import { IpcResponse } from "shared/models/ipc";
export class UtilsService{
@@ -68,11 +68,7 @@ export class UtilsService{
return rm(folderPath, {recursive: true});
}
public ipcSend(channel: string, args?: any){
this.mainWindow.webContents.send(channel, args);
}
public newIpcSenc(channel: string, response: IpcResponse<any>): void{
public ipcSend(channel: string, response: IpcResponse<any>): void{
this.mainWindow.webContents.send(channel, response);
}
@@ -1,4 +1,4 @@
import { BSVersion } from "main/services/bs-version-manager.service";
import { BSVersion } from "main/services/bs-version-lib.service";
import './available-version-item.component.css';
import { useEffect, useState, memo } from "react";
import { BsDownloaderService } from "renderer/services/bs-downloader.service";
@@ -1,4 +1,4 @@
import { BSVersion } from "main/services/bs-version-manager.service";
import { BSVersion } from "main/services/bs-version-lib.service";
import { useEffect, useState } from "react"
import { BSVersionManagerService } from "renderer/services/bs-version-manager.service";
import { filter, take } from "rxjs";
@@ -1,6 +1,6 @@
import { ModalExitCode, ModalResponse, ModalService } from "../../../services/modale.service";
import BeatConflict from "../../../../../assets/images/apngs/beat-conflict.png"
import { BSVersion } from "main/services/bs-version-manager.service";
import { BSVersion } from "main/services/bs-version-lib.service";
import { BsmButton } from "renderer/components/shared/bsm-button.component";
import { BsmImage } from "renderer/components/shared/bsm-image.component";
import { useTranslation } from "renderer/hooks/use-translation.hook";
@@ -1,4 +1,4 @@
import { BSVersion } from "main/services/bs-version-manager.service";
import { BSVersion } from "main/services/bs-version-lib.service";
import { Link, useLocation } from "react-router-dom";
import { BsDownloaderService } from "renderer/services/bs-downloader.service";
import { useEffect, useState } from "react";
@@ -1,50 +1,53 @@
import { useState } from 'react';
import { IpcService } from 'renderer/services/ipc.service';
import './title-bar.component.css'
export default function TitleBar() {
const [maximized, setMaximized] = useState(false);
const ipcService = IpcService.getInstance();
const closeWindow = () => {
window.electron.ipcRenderer.sendMessage('window.close', null);
}
const [maximized, setMaximized] = useState(false);
const maximizeWindow = () => {
window.electron.ipcRenderer.sendMessage('window.maximize', null);
}
const closeWindow = () => {
ipcService.sendLazy('window.close');
}
const minimizeWindow = () => {
window.electron.ipcRenderer.sendMessage('window.minimize', null);
}
const maximizeWindow = () => {
ipcService.sendLazy('window.maximize');
}
const resetWindow = () => {
window.electron.ipcRenderer.sendMessage('window.reset', null);
}
const minimizeWindow = () => {
ipcService.sendLazy('window.minimize');
}
const toogleMaximize = () => {
if(maximized){ resetWindow(); }
else{ maximizeWindow(); }
setMaximized(!maximized);
}
const resetWindow = () => {
ipcService.sendLazy('window.reset');
}
return (
<header id="titlebar" className="min-h-[22px] bg-light-main-color-1 dark:bg-main-color-1 w-screen h-10 flex content-center items-center justify-start z-10">
<div id="drag-region" className='grow basis-0'>
<div id="window-title" className='pl-1'>
<span className='text-gray-800 dark:text-gray-100 font-bold text-xs italic'>BSManager</span>
</div>
</div>
<div id="window-controls" className=''>
<div onClick={minimizeWindow} className="button button text-gray-800 dark:text-gray-200 hover:bg-gray-300 dark:hover:bg-[#4F545C] cursor-pointer" id="min-button" >
<svg aria-hidden="false" width="12" height="12" viewBox="0 0 12 12"><rect fill="currentColor" width="10" height="1" x="1" y="6"> </rect></svg>
</div>
<div onClick={toogleMaximize} className="button text-gray-800 dark:text-gray-200 hover:bg-gray-300 dark:hover:bg-[#4F545C] cursor-pointer" id="max-button">
<svg aria-hidden="false" width="12" height="12" viewBox="0 0 12 12"><rect width="9" height="9" x="1.5" y="1.5" fill="none" stroke="currentColor"> </rect></svg>
</div>
<div onClick={closeWindow} className="button text-gray-800 dark:text-gray-200 cursor-pointer" id="close-button" draggable="false">
<svg aria-hidden="false" width="12" height="12" viewBox="0 0 12 12"><polygon fill="currentColor" fillRule="evenodd" points="11 1.576 6.583 6 11 10.424 10.424 11 6 6.583 1.576 11 1 10.424 5.417 6 1 1.576 1.576 1 6 5.417 10.424 1"> </polygon></svg>
</div>
</div>
</header>
)
const toogleMaximize = () => {
if(maximized){ resetWindow(); }
else{ maximizeWindow(); }
setMaximized(!maximized);
}
return (
<header id="titlebar" className="min-h-[22px] bg-light-main-color-1 dark:bg-main-color-1 w-screen h-10 flex content-center items-center justify-start z-10">
<div id="drag-region" className='grow basis-0'>
<div id="window-title" className='pl-1'>
<span className='text-gray-800 dark:text-gray-100 font-bold text-xs italic'>BSManager</span>
</div>
</div>
<div id="window-controls" className=''>
<div onClick={minimizeWindow} className="button button text-gray-800 dark:text-gray-200 hover:bg-gray-300 dark:hover:bg-[#4F545C] cursor-pointer" id="min-button" >
<svg aria-hidden="false" width="12" height="12" viewBox="0 0 12 12"><rect fill="currentColor" width="10" height="1" x="1" y="6"> </rect></svg>
</div>
<div onClick={toogleMaximize} className="button text-gray-800 dark:text-gray-200 hover:bg-gray-300 dark:hover:bg-[#4F545C] cursor-pointer" id="max-button">
<svg aria-hidden="false" width="12" height="12" viewBox="0 0 12 12"><rect width="9" height="9" x="1.5" y="1.5" fill="none" stroke="currentColor"> </rect></svg>
</div>
<div onClick={closeWindow} className="button text-gray-800 dark:text-gray-200 cursor-pointer" id="close-button" draggable="false">
<svg aria-hidden="false" width="12" height="12" viewBox="0 0 12 12"><polygon fill="currentColor" fillRule="evenodd" points="11 1.576 6.583 6 11 10.424 10.424 11 6 6.583 1.576 11 1 10.424 5.417 6 1 1.576 1.576 1 6 5.417 10.424 1"> </polygon></svg>
</div>
</div>
</header>
)
}
@@ -2,7 +2,7 @@ import { AvailableVersionsSlider } from "../components/available-versions/availa
import { BsDownloaderService } from "../services/bs-downloader.service";
import { Slideshow } from "renderer/components/slideshow/slideshow.component";
import { useEffect, useState } from "react";
import { BSVersion } from "main/services/bs-version-manager.service";
import { BSVersion } from "main/services/bs-version-lib.service";
import { BsmButton } from "renderer/components/shared/bsm-button.component";
import { AnimatePresence, motion } from "framer-motion";
import { useTranslation } from "renderer/hooks/use-translation.hook";
@@ -1,4 +1,4 @@
import { BSVersion } from '../../main/services/bs-version-manager.service';
import { BSVersion } from '../../main/services/bs-version-lib.service';
import { useEffect, useState } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
import BSLogo from '../../../assets/images/apngs/bs-logo.png';
@@ -16,9 +16,17 @@ import { ModalExitCode, ModalService, ModalType } from '../services/modale.servi
import DefautVersionImage from "../../../assets/images/default-version-img.jpg";
import { BsDownloaderService } from 'renderer/services/bs-downloader.service';
import { useTranslation } from 'renderer/hooks/use-translation.hook';
import { IpcService } from 'renderer/services/ipc.service';
export function VersionViewer() {
const configService = ConfigurationService.getInstance();
const bsUninstallerService = BSUninstallerService.getInstance();
const bsVersionManagerService = BSVersionManagerService.getInstance();
const modalService = ModalService.getInsance();
const bsDownloaderService = BsDownloaderService.getInstance();
const ipcService = IpcService.getInstance();
const {state} = useLocation() as {state: BSVersion};
const navigate = useNavigate();
const bsLauncherService = BSLauncherService.getInstance();
@@ -28,12 +36,6 @@ export function VersionViewer() {
const [debugMode, setDebugMode] = useState(false);
const [currentTabIndex, setCurrentTabIndex] = useState(0);
const configService = ConfigurationService.getInstance();
const bsUninstallerService = BSUninstallerService.getInstance();
const bsVersionManagerService = BSVersionManagerService.getInstance();
const modalService = ModalService.getInsance();
const bsDownloaderService = BsDownloaderService.getInstance();
useEffect(() => {
setOculusMode(!!configService.get<boolean>(LaunchMods.OCULUS_MOD));
setDesktopMode(!!configService.get<boolean>(LaunchMods.DESKTOP_MOD));
@@ -73,7 +75,7 @@ export function VersionViewer() {
verifyFiles();
}
else if(id === 1){
window.electron.ipcRenderer.sendMessage("bs-version.open-folder", state);
ipcService.sendLazy("bs-version.open-folder", {args: state});
}
}
@@ -1,7 +1,7 @@
import { DownloadEvent } from 'main/services/bs-installer.service';
import { BehaviorSubject, distinctUntilChanged, filter, debounceTime } from 'rxjs';
import { IpcResponse } from 'shared/models/ipc-models.model';
import { BSVersion } from '../../main/services/bs-version-manager.service'
import { IpcResponse } from 'shared/models/ipc';
import { BSVersion } from '../../main/services/bs-version-lib.service'
import { AuthUserService } from './auth-user.service';
import { BSVersionManagerService } from './bs-version-manager.service';
import { IpcService } from './ipc.service';
+1 -1
View File
@@ -1,5 +1,5 @@
import { LauchOption } from "../../shared/models/launch-models.model";
import { BSVersion } from "../../main/services/bs-version-manager.service";
import { BSVersion } from "../../main/services/bs-version-lib.service";
import { IpcService } from "./ipc.service";
import { BsLaunchResult } from "../../shared/models/launch-models.model";
import { NotificationResult, NotificationService } from "./notification.service";
@@ -1,4 +1,4 @@
import { BSVersion } from "main/services/bs-version-manager.service";
import { BSVersion } from "main/services/bs-version-lib.service";
import { IpcService } from "./ipc.service";
export class BSUninstallerService{
@@ -1,4 +1,4 @@
import { BSVersion } from "../../main/services/bs-version-manager.service";
import { BSVersion } from "../../main/services/bs-version-lib.service";
import { BehaviorSubject } from "rxjs";
import { IpcService } from "./ipc.service";
+1 -2
View File
@@ -1,5 +1,5 @@
import { Observable } from "rxjs";
import { IpcRequest, IpcResponse } from "../../shared/models/ipc-models.model";
import { IpcRequest, IpcResponse } from "shared/models/ipc";
export class IpcService {
@@ -34,7 +34,6 @@ export class IpcService {
}
public watch<T>(channel: string): Observable<IpcResponse<T>>{
if(this.channelObservables.has(channel)){ return this.channelObservables.get(channel) as Observable<IpcResponse<T>>; }
const obs = new Observable<IpcResponse<T>>(observer => {
-12
View File
@@ -1,12 +0,0 @@
import { BsmException } from "./bsm-exception.model";
export interface IpcRequest<T>{
args?: T,
responceChannel?: string
}
export interface IpcResponse<T>{
data?: T,
error?: BsmException,
success: boolean,
}
+2
View File
@@ -0,0 +1,2 @@
export { IpcRequest } from "./ipc-request.interface"
export { IpcResponse } from "./ipc-response.interface"
@@ -0,0 +1,4 @@
export interface IpcRequest<T>{
args?: T,
responceChannel?: string
}
@@ -0,0 +1,7 @@
import { BsmException } from "../bsm-exception.model";
export interface IpcResponse<T>{
data?: T,
error?: BsmException,
success: boolean,
}
+1 -1
View File
@@ -1,4 +1,4 @@
import { BSVersion } from "main/services/bs-version-manager.service";
import { BSVersion } from "main/services/bs-version-lib.service";
export interface LauchOption {
version: BSVersion,