mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
add alpha version toggle in settings and update auto-updater configuration
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { autoUpdater, CancellationToken, ProgressInfo } from "electron-updater";
|
||||
import { StaticConfigurationService } from "main/services/static-configuration.service";
|
||||
import log from "electron-log";
|
||||
import { gt } from "semver";
|
||||
import { Progression } from "main/helpers/fs.helpers";
|
||||
@@ -7,6 +8,8 @@ import { Observable } from "rxjs";
|
||||
export class AutoUpdaterService {
|
||||
private static instance: AutoUpdaterService;
|
||||
|
||||
private static readonly staticConfig = StaticConfigurationService.getInstance();
|
||||
|
||||
public static getInstance(): AutoUpdaterService {
|
||||
if (!AutoUpdaterService.instance) {
|
||||
AutoUpdaterService.instance = new AutoUpdaterService();
|
||||
@@ -20,6 +23,10 @@ export class AutoUpdaterService {
|
||||
}
|
||||
|
||||
public async isUpdateAvailable(): Promise<boolean> {
|
||||
AutoUpdaterService.staticConfig.take("use-alpha", useAlpha => {
|
||||
autoUpdater.allowPrerelease = useAlpha;
|
||||
});
|
||||
|
||||
return autoUpdater.checkForUpdates()
|
||||
.then(info => {
|
||||
return !!info?.updateInfo && gt(
|
||||
@@ -47,6 +54,7 @@ export class AutoUpdaterService {
|
||||
autoUpdater.addListener("download-progress", progressListener);
|
||||
autoUpdater.addListener("update-downloaded", downloadedListener);
|
||||
|
||||
|
||||
const cancelToken = new CancellationToken();
|
||||
|
||||
autoUpdater.downloadUpdate(cancelToken)
|
||||
|
||||
@@ -90,6 +90,7 @@ export interface StaticConfigKeyValues {
|
||||
"use-symlinks": boolean;
|
||||
"use-system-proxy": boolean;
|
||||
"last-version-launched": BSVersion;
|
||||
"use-alpha": boolean;
|
||||
|
||||
// Linux Specific static configs
|
||||
"proton-folder": string;
|
||||
|
||||
@@ -545,11 +545,13 @@ function AdvancedSettings() {
|
||||
const [hardwareAccelerationEnabled, setHardwareAccelerationEnabled] = useState(true);
|
||||
const [useSymlink, setUseSymlink] = useState(false);
|
||||
const [useSystemProxy, setUseSystemProxy] = useState(false);
|
||||
const [useAlpha, setUseAlpha] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
staticConfig.get("disable-hadware-acceleration").then(disabled =>setHardwareAccelerationEnabled(() => disabled !== true));
|
||||
staticConfig.get("use-symlinks").then(useSymlinks => setUseSymlink(() => useSymlinks));
|
||||
staticConfig.get("use-system-proxy").then(useSystemProxy => setUseSystemProxy(() => useSystemProxy));
|
||||
staticConfig.get("use-alpha").then(useAlpha => setUseAlpha(() => useAlpha));
|
||||
}, []);
|
||||
|
||||
const onChangeHardwareAcceleration = async (newHardwareAccelerationEnabled: boolean) => {
|
||||
@@ -630,6 +632,36 @@ function AdvancedSettings() {
|
||||
setUseSystemProxy(() => newUseSystemProxy);
|
||||
}
|
||||
|
||||
const onChangeUseAlpha = async (newUseAlpha: boolean) => {
|
||||
|
||||
if (window.electron.platform !== "win32" || newUseAlpha === useAlpha) {
|
||||
return;
|
||||
}
|
||||
|
||||
const res = await modal.openModal(BasicModal, { data: {
|
||||
title: "pages.settings.advanced.use-alpha.modal.title",
|
||||
body: "pages.settings.advanced.use-alpha.modal.body",
|
||||
image: BeatConflict,
|
||||
buttons: [
|
||||
{ id: "cancel", text: "misc.cancel", type: "cancel" },
|
||||
{ id: "confirm", text: "pages.settings.advanced.use-alpha.modal.confirm-btn", type: "error", onClick: () => true}
|
||||
]
|
||||
}});
|
||||
|
||||
if(res.exitCode !== ModalExitCode.COMPLETED || res.data !== "confirm"){ return; }
|
||||
|
||||
const { error } = await tryit(() => staticConfig.set("use-alpha", newUseAlpha));
|
||||
|
||||
if(error){
|
||||
notification.notifyError({ title: "notifications.types.error", desc: "pages.settings.advanced.use-alpha.error-notification.message" });
|
||||
return;
|
||||
}
|
||||
|
||||
setUseAlpha(() => newUseAlpha);
|
||||
|
||||
await lastValueFrom(ipc.sendV2("restart-app"));
|
||||
}
|
||||
|
||||
const advancedItems: Item[] = [{
|
||||
checked: hardwareAccelerationEnabled,
|
||||
text: t.text("pages.settings.advanced.hardware-acceleration.title"),
|
||||
@@ -649,6 +681,12 @@ function AdvancedSettings() {
|
||||
desc: t.text("pages.settings.advanced.use-system-proxy.description"),
|
||||
onChange: onChangeUseSystemProxy
|
||||
});
|
||||
advancedItems.push({
|
||||
checked: useAlpha,
|
||||
text: t.text("pages.settings.advanced.use-alpha.title"),
|
||||
desc: t.text("pages.settings.advanced.use-alpha.description"),
|
||||
onChange: onChangeUseAlpha
|
||||
});
|
||||
}
|
||||
|
||||
return <SettingContainer title="pages.settings.advanced.title" description="pages.settings.advanced.description">
|
||||
|
||||
Reference in New Issue
Block a user