mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
Refactor AutoUpdaterService and remove unused code
This commit is contained in:
@@ -32,9 +32,4 @@ ipc.on<void>("restore-original-oculus-folder", (_, reply) => {
|
||||
));
|
||||
});
|
||||
|
||||
ipc.on<boolean>("have-been-updated", (_, reply) => {
|
||||
const updaterService = AutoUpdaterService.getInstance();
|
||||
reply(from(updaterService.getHaveBeenUpdated()));
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -59,19 +59,4 @@ export class AutoUpdaterService {
|
||||
public quitAndInstall() {
|
||||
autoUpdater.quitAndInstall();
|
||||
}
|
||||
|
||||
|
||||
public getHaveBeenUpdated(): Observable<boolean> {
|
||||
const haveBeenUpdated = this.ConfigurationService.get(this.HAVE_BEEN_UPDATED_KEY);
|
||||
return new Observable<boolean>((observer) => {
|
||||
observer.next(haveBeenUpdated as boolean);
|
||||
observer.complete();
|
||||
});
|
||||
}
|
||||
|
||||
public setHaveBeenUpdated(value: boolean): void {
|
||||
this.ConfigurationService.set(this.HAVE_BEEN_UPDATED_KEY, value);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import { ProgressBarService } from "./progress-bar.service";
|
||||
import { I18nService } from "./i18n.service";
|
||||
import { ModalService } from "renderer/services/modale.service";
|
||||
import { ChangelogModal } from "renderer/components/modal/modal-types/chabgelog-modal/changelog-modal.component";
|
||||
import { ConfigurationService } from "./configuration.service";
|
||||
|
||||
export interface Changelog {
|
||||
[version: string]: ChangelogVersion;
|
||||
@@ -27,7 +28,7 @@ export class AutoUpdaterService {
|
||||
|
||||
private modal: ModalService;
|
||||
|
||||
private readonly changelog: BehaviorSubject<Changelog>;
|
||||
private configurationService: ConfigurationService;
|
||||
|
||||
public static getInstance(): AutoUpdaterService {
|
||||
if (!AutoUpdaterService.instance) {
|
||||
@@ -41,6 +42,7 @@ export class AutoUpdaterService {
|
||||
this.ipcService = IpcService.getInstance();
|
||||
this.i18nService = I18nService.getInstance();
|
||||
this.modal = ModalService.getInstance();
|
||||
this.configurationService = ConfigurationService.getInstance();
|
||||
|
||||
|
||||
this.downloadProgress$ = this.ipcService.watch<number>("update-download-progress").pipe(map(res => (res.success ? res.data : 0)));
|
||||
@@ -63,10 +65,15 @@ export class AutoUpdaterService {
|
||||
this.ipcService.sendLazy("install-update");
|
||||
}
|
||||
|
||||
public getHaveBeenUpdated(): Observable<boolean>{
|
||||
return this.ipcService.sendV2<boolean>("have-been-updated");
|
||||
public getHaveBeenUpdated(): boolean {
|
||||
return this.configurationService.get("have-been-updated");
|
||||
}
|
||||
|
||||
public setHaveBeenUpdated(value: boolean){
|
||||
this.configurationService.set("have-been-updated", value);
|
||||
}
|
||||
|
||||
|
||||
private async getChangelog(): Promise<Changelog> {
|
||||
const path = `https://raw.githubusercontent.com/Zagrios/bs-manager/feature/add-changelog-modal/178/assets/jsons/changelogs/${this.i18nService.currentLanguage.split("-")[0]}.json`
|
||||
const response = await fetch(path);
|
||||
@@ -102,10 +109,12 @@ export class AutoUpdaterService {
|
||||
|
||||
public async showChangelog(): Promise<void>{
|
||||
try{
|
||||
const currentVersion = await lastValueFrom(this.getAppVersion());
|
||||
const changelog = await this.getChangelogVersion(currentVersion);
|
||||
if(this.getHaveBeenUpdated()){
|
||||
const currentVersion = await lastValueFrom(this.getAppVersion());
|
||||
const changelog = await this.getChangelogVersion(currentVersion);
|
||||
|
||||
this.modal.openModal(ChangelogModal, changelog);
|
||||
this.modal.openModal(ChangelogModal, changelog);
|
||||
}
|
||||
}
|
||||
catch(error){
|
||||
this.ipcService.sendLazy("log-error", {args: error});
|
||||
|
||||
Reference in New Issue
Block a user