diff --git a/src/backend/alsListener.tsx b/src/backend/alsListener.tsx index f59dff3..9f81f96 100644 --- a/src/backend/alsListener.tsx +++ b/src/backend/alsListener.tsx @@ -40,8 +40,11 @@ export const smoothTimeInfo = { step: 50 }; -let pollingRate = 100; // Time in milliseconds -let smoothTime = 500; // Time in milliseconds +export const DEFAULT_POLLING_RATE = 100; +export const DEFAULT_SMOOTH_TIME = 500; + +let pollingRate = DEFAULT_POLLING_RATE; // Time in milliseconds +let smoothTime = DEFAULT_SMOOTH_TIME; // Time in milliseconds const stepCount = 10; // Less steps = smoother transition let previousAlsValues = Array(75).fill(-1); // Increase length to increase read times (less sensitive to changes) diff --git a/src/redux-modules/uiSlice.tsx b/src/redux-modules/uiSlice.tsx index 7101dff..3408ebc 100644 --- a/src/redux-modules/uiSlice.tsx +++ b/src/redux-modules/uiSlice.tsx @@ -8,6 +8,8 @@ import { getServerApi } from '../backend/utils'; import { + DEFAULT_POLLING_RATE, + DEFAULT_SMOOTH_TIME, clearAlsListener, enableAlsListener, setPollRate, @@ -35,8 +37,8 @@ const initialState: UiStateType = { currentDisplayName: undefined, pluginVersionNum: '', alsInfo: { - pollingRate: 100, - smoothTime: 500 + pollingRate: DEFAULT_POLLING_RATE, + smoothTime: DEFAULT_SMOOTH_TIME } }; @@ -76,7 +78,10 @@ export const uiSlice = createSlice({ state.alsEnabled = Boolean(action.payload?.alsEnabled); } if (action.payload?.alsInfo) { + const { pollingRate, smoothTime } = action.payload.alsInfo; state.alsInfo = action.payload.alsInfo; + setPollRate(pollingRate || DEFAULT_POLLING_RATE); + setSmoothTime(smoothTime || DEFAULT_SMOOTH_TIME); } }); builder.addCase(setCurrentGameId, (state, action) => {