Skip to content

Commit

Permalink
[feat] added auto update option on advance settings for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
silentrald committed Jan 31, 2025
1 parent 413996f commit 415e903
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 11 deletions.
7 changes: 7 additions & 0 deletions assets/jsons/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,13 @@
"error-notification": {
"message": "An error occurred, unable to change system proxy settings."
}
},
"auto-update": {
"title": "Auto Update",
"description": "BSManager will automatically update when you launch the application.",
"error-notification": {
"message": "An error occurred, unable to change auto update settings."
}
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ if (!gotTheLock) {

app.whenReady().then(() => {



app.setAppUserModelId(APP_NAME);

initServicesMustBeInitialized();
Expand All @@ -132,10 +130,12 @@ if (!gotTheLock) {
DeepLinkService.getInstance().dispatchLinkOpened(deepLink);
} else if (associatedFile) {
FileAssociationService.getInstance().handleFileAssociation(associatedFile);
} else if (process.platform === "linux") {
createWindow("index.html");
} else {
createWindow(process.platform === "linux"
? "index.html" : "launcher.html"
);
const autoUpdate = StaticConfigurationService.getInstance().get("auto-update");
createWindow(autoUpdate === undefined || autoUpdate === true
? "launcher.html" : "index.html");
}

SteamLauncherService.getInstance().restoreSteamVR();
Expand Down
5 changes: 3 additions & 2 deletions src/main/services/static-configuration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export class StaticConfigurationService {
return this.store.has(key);
}

public get<K extends StaticConfigKeys>(key: K): StaticConfigKeyValues[K] {
return this.store.get<K>(key) as StaticConfigKeyValues[K];
public get<K extends StaticConfigKeys>(key: K, defaultValue?: StaticConfigKeyValues[K]): StaticConfigKeyValues[K] {
return this.store.get<K>(key, defaultValue) as StaticConfigKeyValues[K];
}

public take<K extends StaticConfigKeys>(key: K, cb: (val: StaticConfigKeyValues[K]) => void): void {
Expand Down Expand Up @@ -90,6 +90,7 @@ export interface StaticConfigKeyValues {
"use-symlinks": boolean;
"use-system-proxy": boolean;
"last-version-launched": BSVersion;
"auto-update": boolean;

// Linux Specific static configs
"proton-folder": string;
Expand Down
42 changes: 38 additions & 4 deletions src/renderer/pages/settings-page.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -545,11 +545,17 @@ function AdvancedSettings() {
const [hardwareAccelerationEnabled, setHardwareAccelerationEnabled] = useState(true);
const [useSymlink, setUseSymlink] = useState(false);
const [useSystemProxy, setUseSystemProxy] = useState(false);
const [autoUpdate, setAutoUpdate] = useState(true);


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));

if (window.electron.platform === "win32") {
staticConfig.get("use-symlinks").then(useSymlinks => setUseSymlink(() => useSymlinks));
staticConfig.get("use-system-proxy").then(useSystemProxy => setUseSystemProxy(() => useSystemProxy));
staticConfig.get("auto-update").then(value => setAutoUpdate(() => value));
}
}, []);

const onChangeHardwareAcceleration = async (newHardwareAccelerationEnabled: boolean) => {
Expand Down Expand Up @@ -630,12 +636,40 @@ function AdvancedSettings() {
setUseSystemProxy(() => newUseSystemProxy);
}

const advancedItems: Item[] = [{
const onChangeAutoUpdate = async (newAutoUpdate: boolean) => {
if (window.electron.platform !== "win32") {
return;
}

const { error } = await tryit(() => staticConfig.set("auto-update", newAutoUpdate));
if (error) {
notification.notifyError({
title: "notifications.types.error",
desc: "pages.settings.advanced.auto-update.error-notification.message",
});
}

setAutoUpdate(() => newAutoUpdate);
}

const advancedItems: Item[] = [];

if (window.electron.platform === "win32") {
advancedItems.push({
checked: autoUpdate,
text: t.text("pages.settings.advanced.auto-update.title"),
desc: t.text("pages.settings.advanced.auto-update.description"),
onChange: onChangeAutoUpdate
});
}

advancedItems.push({
checked: hardwareAccelerationEnabled,
text: t.text("pages.settings.advanced.hardware-acceleration.title"),
desc: t.text("pages.settings.advanced.hardware-acceleration.description"),
onChange: onChangeHardwareAcceleration
}];
});

if (window.electron.platform === "win32") {
advancedItems.push({
checked: useSymlink,
Expand Down

0 comments on commit 415e903

Please sign in to comment.