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,
|
||||
checkIfNewerReleaseExist as checkNewVersion,
|
||||
isPresetValid,
|
||||
appContextSettingsKey,
|
||||
};
|
||||
|
@ -6,13 +6,13 @@ import RyzenControllerAppContext, {
|
||||
persistentSave,
|
||||
getSettingDefinition,
|
||||
executeRyzenAdjUsingPreset,
|
||||
appContextSettingsKey,
|
||||
} from "../contexts/RyzenControllerAppContext";
|
||||
import RyzenAdjScene from "../scenes/RyzenAdjScene";
|
||||
import PresetsScene from "../scenes/PresetsScene";
|
||||
import SettingsScene from "../scenes/SettingsScene";
|
||||
import NotificationContext from "../contexts/NotificationContext";
|
||||
import { getTranslation } from "../contexts/LocaleContext";
|
||||
import AppVersion from "../contexts/AppVersion";
|
||||
const electronSettings = window.require("electron-settings");
|
||||
const powerMonitor = window.require("electron").remote.powerMonitor;
|
||||
|
||||
@ -32,10 +32,8 @@ class Scene extends React.Component<{}, RyzenControllerAppContextType> {
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
let settings = electronSettings.get(AppVersion.string);
|
||||
if (settings) {
|
||||
settings = settings.settings;
|
||||
} else {
|
||||
let settings = electronSettings.get(`${appContextSettingsKey}.settings`);
|
||||
if (!settings) {
|
||||
settings = defaultRyzenControllerAppContext.settings;
|
||||
}
|
||||
let newSettingsPromises: Array<Promise<string | boolean>> = [];
|
||||
@ -63,7 +61,7 @@ class Scene extends React.Component<{}, RyzenControllerAppContextType> {
|
||||
}
|
||||
|
||||
powerMonitor.on("unlock-screen", () => {
|
||||
const presetName = electronSettings.get(AppVersion.string)?.settings?.onSessionResume;
|
||||
const presetName = electronSettings.get(`${appContextSettingsKey}.settings.onSessionResume`);
|
||||
if (presetName) {
|
||||
executeRyzenAdjUsingPreset(presetName);
|
||||
}
|
||||
@ -80,15 +78,15 @@ class Scene extends React.Component<{}, RyzenControllerAppContextType> {
|
||||
|
||||
handleBatteryStatusChange() {
|
||||
powerMonitor.on("on-ac", () => {
|
||||
const presetName = electronSettings.get(AppVersion.string)?.settings?.onLaptopPluggedIn;
|
||||
if (presetName !== false && presetName !== "") {
|
||||
const presetName = electronSettings.get(`${appContextSettingsKey}.settings.onLaptopPluggedIn`);
|
||||
if (presetName) {
|
||||
executeRyzenAdjUsingPreset(presetName);
|
||||
}
|
||||
});
|
||||
|
||||
powerMonitor.on("on-battery", () => {
|
||||
const presetName = electronSettings.get(AppVersion.string)?.settings?.onLaptopPluggedOut;
|
||||
if (presetName !== false && presetName !== "") {
|
||||
const presetName = electronSettings.get(`${appContextSettingsKey}.settings.onLaptopPluggedOut`);
|
||||
if (presetName) {
|
||||
executeRyzenAdjUsingPreset(presetName);
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user