Add ConfigurationService and methods for getting

and setting haveBeenUpdated flag
This commit is contained in:
Shidorien
2023-11-24 02:46:34 +01:00
parent 0d7c160b24
commit 8c9846d751
+23
View File
@@ -2,12 +2,18 @@ import { autoUpdater } from "electron-updater";
import log from "electron-log";
import { UtilsService } from "./utils.service";
import { gt } from "semver";
import { Observable } from "rxjs";
import { ConfigurationService } from "./configuration.service";
export class AutoUpdaterService {
private static instance: AutoUpdaterService;
private readonly utilsService: UtilsService;
private readonly ConfigurationService: ConfigurationService
private readonly HAVE_BEEN_UPDATED_KEY : string;
public static getInstance(): AutoUpdaterService {
if (!AutoUpdaterService.instance) {
AutoUpdaterService.instance = new AutoUpdaterService();
@@ -20,6 +26,8 @@ export class AutoUpdaterService {
autoUpdater.autoDownload = false;
this.utilsService = UtilsService.getInstance();
this.ConfigurationService = ConfigurationService.getInstance();
this.HAVE_BEEN_UPDATED_KEY = "haveBeenUpdated";
}
public isUpdateAvailable(): Promise<boolean> {
@@ -51,4 +59,19 @@ 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);
}
}