From 0e0108cb848d4db587cfcb7b1b1c6d0004cc4c9b Mon Sep 17 00:00:00 2001 From: Aarron Lee Date: Tue, 23 Jan 2024 17:57:23 -0500 Subject: [PATCH] cleanup middleware --- main.py | 10 ++----- src/redux-modules/settingsMiddleware.ts | 36 +++++------------------ src/redux-modules/steamPatchMiddleware.ts | 8 ++--- 3 files changed, 12 insertions(+), 42 deletions(-) diff --git a/main.py b/main.py index 77949fe..21e8211 100644 --- a/main.py +++ b/main.py @@ -103,10 +103,6 @@ async def save_tdp(self, tdpProfiles, currentGameId, advanced): merge_tdp_profiles(tdpProfiles) persist_setting('advanced', advanced) - steam_patch_enabled = advanced_options.get_setting( - advanced_options.DefaultSettings.ENABLE_STEAM_PATCH.value - ) - tdp_profile = get_active_tdp_profile(currentGameId) tdp = tdp_profile.get('tdp', 12) smt = tdp_profile.get('smt', True) @@ -114,12 +110,10 @@ async def save_tdp(self, tdpProfiles, currentGameId, advanced): try: with file_timeout.time_limit(3): - if not steam_patch_enabled: - ryzenadj(tdp) + ryzenadj(tdp) set_smt(smt) set_cpu_boost(cpu_boost) - if not steam_patch_enabled: - set_gpu_frequency(currentGameId) + set_gpu_frequency(currentGameId) except Exception as e: logging.error(f'main#save_tdp file timeout {e}') diff --git a/src/redux-modules/settingsMiddleware.ts b/src/redux-modules/settingsMiddleware.ts index 9115a4f..b1d18e3 100644 --- a/src/redux-modules/settingsMiddleware.ts +++ b/src/redux-modules/settingsMiddleware.ts @@ -27,10 +27,10 @@ import { ServerAPI } from "decky-frontend-lib"; import { cleanupAction, resumeAction } from "./extraActions"; const resetTdpActionTypes = [ - setCurrentGameInfo.type, setEnableTdpProfiles.type, updateTdpProfiles.type, updatePollRate.type, + setCurrentGameInfo.type, setPolling.type, updateInitialLoad.type, updateAdvancedOption.type, @@ -45,6 +45,7 @@ const BACKGROUND_POLL_RATE = 10000; const resetPolling = (store: any) => { if (pollIntervalId) { clearInterval(pollIntervalId); + pollIntervalId = undefined; } const state = store.getState(); @@ -83,7 +84,12 @@ export const settingsMiddleware = advancedState[AdvancedOptionsEnum.STEAM_PATCH] ); - if (!steamPatchEnabled) { + if (steamPatchEnabled) { + if (pollIntervalId) { + clearInterval(pollIntervalId); + pollIntervalId = undefined; + } + } else { const activeGameId = activeGameIdSelector(state); if (action.type === resumeAction.type) { @@ -114,29 +120,6 @@ export const settingsMiddleware = ); } - if (action.type === setCurrentGameInfo.type) { - const { - settings: { previousGameId }, - } = state; - - if (previousGameId !== state.currentGameId) { - // update TDP to new game's TDP value, if appropriate to do so - saveTdpProfiles( - state.settings.tdpProfiles, - activeGameId, - advancedState - ); - } - } - - if (action.type === updateTdpProfiles.type) { - saveTdpProfiles( - state.settings.tdpProfiles, - activeGameId, - advancedState - ); - } - if (action.type === updatePollRate.type) { // action.type == number (rate in ms) setSetting({ @@ -166,9 +149,6 @@ export const settingsMiddleware = clearInterval(pollIntervalId); } } - } else { - // steamPatchEnabled, disable polling - if (pollIntervalId) clearInterval(pollIntervalId); } return result; diff --git a/src/redux-modules/steamPatchMiddleware.ts b/src/redux-modules/steamPatchMiddleware.ts index a3a9830..26f5663 100644 --- a/src/redux-modules/steamPatchMiddleware.ts +++ b/src/redux-modules/steamPatchMiddleware.ts @@ -53,15 +53,11 @@ export const steamPatchMiddleware = } if (action.type === resumeAction.type) { - if (steamPatchEnabled) { - setValuesForGameId(id); - } + setValuesForGameId(id); } if (action.type === setCurrentGameInfo.type) { - if (steamPatchEnabled) { - setValuesForGameId(id); - } + setValuesForGameId(id); } if (saveToBackendTypes.includes(action.type)) {