mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
service qui se chargera des téléchargements
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { DownloadInfo } from '../../main/ipcs/bs-download-ipcs';
|
||||
import { BSVersion } from '../../main/services/bs-version-manager.service'
|
||||
import { ModalExitCode, ModalService, ModalType } from './modale.service';
|
||||
|
||||
export class BsDownloaderService{
|
||||
|
||||
private static instance: BsDownloaderService;
|
||||
|
||||
private readonly modalService: ModalService = ModalService.getInsance();
|
||||
|
||||
private constructor(){
|
||||
window.electron.ipcRenderer.on('bs-download.not-connected', async (bsVersion: BSVersion) => {
|
||||
const res = await this.modalService.openModal(ModalType.STEAM_LOGIN);
|
||||
if(res.exitCode !== ModalExitCode.COMPLETED){ return; }
|
||||
window.electron.ipcRenderer.sendMessage('bs-download.start', {bsVersion: bsVersion, username: res.data.username, password: res.data.password, stay: res.data.stay} as DownloadInfo)
|
||||
});
|
||||
}
|
||||
|
||||
public static getInstance(){
|
||||
if(!BsDownloaderService.instance){ BsDownloaderService.instance = new BsDownloaderService(); }
|
||||
return BsDownloaderService.instance;
|
||||
}
|
||||
|
||||
public async download(bsVersion: BSVersion){
|
||||
let username = localStorage.getItem("username");
|
||||
if(!username){
|
||||
const res = await this.modalService.openModal(ModalType.STEAM_LOGIN);
|
||||
if(res.exitCode !== ModalExitCode.COMPLETED){ return; }
|
||||
if(res.data.stay){ localStorage.setItem("username", res.data.username); }
|
||||
window.electron.ipcRenderer.sendMessage('bs-download.start', {bsVersion: bsVersion, username: res.data.username, password: res.data.password, stay: res.data.stay} as DownloadInfo);
|
||||
}
|
||||
else{
|
||||
window.electron.ipcRenderer.sendMessage('bs-download.start', {bsVersion: bsVersion, username: username} as DownloadInfo);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user