mirror of
https://gitlab.com/ryzen-controller-team/ryzen-controller.git
synced 2024-12-22 10:03:28 +07:00
fix: Auto apply presets wasn't working as expected in some cases.
This commit is contained in:
parent
347b05bad7
commit
5629f8034a
@ -416,4 +416,5 @@ export {
|
|||||||
executeRyzenAdjUsingPreset,
|
executeRyzenAdjUsingPreset,
|
||||||
checkIfNewerReleaseExist as checkNewVersion,
|
checkIfNewerReleaseExist as checkNewVersion,
|
||||||
isPresetValid,
|
isPresetValid,
|
||||||
|
appContextSettingsKey,
|
||||||
};
|
};
|
||||||
|
@ -6,13 +6,13 @@ import RyzenControllerAppContext, {
|
|||||||
persistentSave,
|
persistentSave,
|
||||||
getSettingDefinition,
|
getSettingDefinition,
|
||||||
executeRyzenAdjUsingPreset,
|
executeRyzenAdjUsingPreset,
|
||||||
|
appContextSettingsKey,
|
||||||
} from "../contexts/RyzenControllerAppContext";
|
} from "../contexts/RyzenControllerAppContext";
|
||||||
import RyzenAdjScene from "../scenes/RyzenAdjScene";
|
import RyzenAdjScene from "../scenes/RyzenAdjScene";
|
||||||
import PresetsScene from "../scenes/PresetsScene";
|
import PresetsScene from "../scenes/PresetsScene";
|
||||||
import SettingsScene from "../scenes/SettingsScene";
|
import SettingsScene from "../scenes/SettingsScene";
|
||||||
import NotificationContext from "../contexts/NotificationContext";
|
import NotificationContext from "../contexts/NotificationContext";
|
||||||
import { getTranslation } from "../contexts/LocaleContext";
|
import { getTranslation } from "../contexts/LocaleContext";
|
||||||
import AppVersion from "../contexts/AppVersion";
|
|
||||||
const electronSettings = window.require("electron-settings");
|
const electronSettings = window.require("electron-settings");
|
||||||
const powerMonitor = window.require("electron").remote.powerMonitor;
|
const powerMonitor = window.require("electron").remote.powerMonitor;
|
||||||
|
|
||||||
@ -32,10 +32,8 @@ class Scene extends React.Component<{}, RyzenControllerAppContextType> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
let settings = electronSettings.get(AppVersion.string);
|
let settings = electronSettings.get(`${appContextSettingsKey}.settings`);
|
||||||
if (settings) {
|
if (!settings) {
|
||||||
settings = settings.settings;
|
|
||||||
} else {
|
|
||||||
settings = defaultRyzenControllerAppContext.settings;
|
settings = defaultRyzenControllerAppContext.settings;
|
||||||
}
|
}
|
||||||
let newSettingsPromises: Array<Promise<string | boolean>> = [];
|
let newSettingsPromises: Array<Promise<string | boolean>> = [];
|
||||||
@ -63,7 +61,7 @@ class Scene extends React.Component<{}, RyzenControllerAppContextType> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
powerMonitor.on("unlock-screen", () => {
|
powerMonitor.on("unlock-screen", () => {
|
||||||
const presetName = electronSettings.get(AppVersion.string)?.settings?.onSessionResume;
|
const presetName = electronSettings.get(`${appContextSettingsKey}.settings.onSessionResume`);
|
||||||
if (presetName) {
|
if (presetName) {
|
||||||
executeRyzenAdjUsingPreset(presetName);
|
executeRyzenAdjUsingPreset(presetName);
|
||||||
}
|
}
|
||||||
@ -80,15 +78,15 @@ class Scene extends React.Component<{}, RyzenControllerAppContextType> {
|
|||||||
|
|
||||||
handleBatteryStatusChange() {
|
handleBatteryStatusChange() {
|
||||||
powerMonitor.on("on-ac", () => {
|
powerMonitor.on("on-ac", () => {
|
||||||
const presetName = electronSettings.get(AppVersion.string)?.settings?.onLaptopPluggedIn;
|
const presetName = electronSettings.get(`${appContextSettingsKey}.settings.onLaptopPluggedIn`);
|
||||||
if (presetName !== false && presetName !== "") {
|
if (presetName) {
|
||||||
executeRyzenAdjUsingPreset(presetName);
|
executeRyzenAdjUsingPreset(presetName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
powerMonitor.on("on-battery", () => {
|
powerMonitor.on("on-battery", () => {
|
||||||
const presetName = electronSettings.get(AppVersion.string)?.settings?.onLaptopPluggedOut;
|
const presetName = electronSettings.get(`${appContextSettingsKey}.settings.onLaptopPluggedOut`);
|
||||||
if (presetName !== false && presetName !== "") {
|
if (presetName) {
|
||||||
executeRyzenAdjUsingPreset(presetName);
|
executeRyzenAdjUsingPreset(presetName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user