allow user to set sleep time
This commit is contained in:
committed by
Lei Nelissen
parent
34b3cd3ba3
commit
cf29516c00
@@ -55,6 +55,18 @@ const persistConfig: PersistConfig<Omit<AppState, '_persist'>> = {
|
||||
}
|
||||
};
|
||||
},
|
||||
// @ts-expect-error migrations are poorly typed
|
||||
4: (state: AppState) => {
|
||||
return {
|
||||
...state,
|
||||
settings: {
|
||||
...state.settings,
|
||||
enableSleepTimer: false,
|
||||
sleepTime: 60,
|
||||
remainingSleepTime: 0
|
||||
}
|
||||
};
|
||||
},
|
||||
})
|
||||
};
|
||||
|
||||
|
||||
@@ -7,3 +7,6 @@ export const setOnboardingStatus = createAction<boolean>('SET_ONBOARDING_STATUS'
|
||||
export const setReceivedErrorReportingAlert = createAction<void>('SET_RECEIVED_ERROR_REPORTING_ALERT');
|
||||
export const setEnablePlaybackReporting = createAction<boolean>('SET_ENABLE_PLAYBACK_REPORTING');
|
||||
export const setColorScheme = createAction<ColorScheme>('SET_COLOR_SCHEME');
|
||||
export const setSleepTime = createAction<number>('SET_SLEEP_TIME');
|
||||
export const setEnableSleepTimer = createAction<boolean>('SET_ENABLE_SLEEP_TIMER');
|
||||
export const setRemainingSleepTime = createAction<number>('SET_REMAINING_SLEEP_TIME');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import { setReceivedErrorReportingAlert, setBitrate, setJellyfinCredentials, setOnboardingStatus, setEnablePlaybackReporting, setColorScheme } from './actions';
|
||||
import { setReceivedErrorReportingAlert, setBitrate, setJellyfinCredentials, setOnboardingStatus, setEnablePlaybackReporting, setColorScheme, setSleepTime, setEnableSleepTimer, setRemainingSleepTime } from './actions';
|
||||
import { ColorScheme } from './types';
|
||||
|
||||
interface State {
|
||||
@@ -14,6 +14,7 @@ interface State {
|
||||
hasReceivedErrorReportingAlert: boolean;
|
||||
enablePlaybackReporting: boolean;
|
||||
colorScheme: ColorScheme;
|
||||
sleepTime: number;
|
||||
}
|
||||
|
||||
const initialState: State = {
|
||||
@@ -22,6 +23,7 @@ const initialState: State = {
|
||||
hasReceivedErrorReportingAlert: false,
|
||||
enablePlaybackReporting: true,
|
||||
colorScheme: ColorScheme.System,
|
||||
sleepTime: 60,
|
||||
};
|
||||
|
||||
const settings = createReducer(initialState, builder => {
|
||||
@@ -49,6 +51,18 @@ const settings = createReducer(initialState, builder => {
|
||||
...state,
|
||||
colorScheme: action.payload,
|
||||
}));
|
||||
builder.addCase(setSleepTime, (state, action) => ({
|
||||
...state,
|
||||
sleepTime: action.payload,
|
||||
}));
|
||||
builder.addCase(setEnableSleepTimer, (state, action) => ({
|
||||
...state,
|
||||
enableSleepTimer: action.payload,
|
||||
}));
|
||||
builder.addCase(setRemainingSleepTime, (state, action) => ({
|
||||
...state,
|
||||
remainingSleepTime: action.payload,
|
||||
}));
|
||||
});
|
||||
|
||||
export default settings;
|
||||
Reference in New Issue
Block a user