55526dbadc
* Front: Add peristance dependencies * Front: Fix Cross-platform persistance * Front: Create Settings Slice * Front: Use Redux State for settings * Front: Check if access token is still valid * Front: Create Language Gate to set correct language at startup * Front: BEtter handling of Access Token validity
36 lines
987 B
TypeScript
36 lines
987 B
TypeScript
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
|
|
|
export type SettingsState = {
|
|
colorScheme: "dark" | "light" | "system",
|
|
enablePushNotifications: boolean,
|
|
enableMailNotifications: boolean,
|
|
enableLessongsReminders: boolean,
|
|
enableReleaseAlerts: boolean,
|
|
preferedLevel: 'easy' | 'medium' | 'hard',
|
|
colorBlind: boolean,
|
|
micLevel: number,
|
|
preferedInputName?: string
|
|
}
|
|
|
|
export const settingsSlice = createSlice({
|
|
name: 'settings',
|
|
initialState: {
|
|
settings: <SettingsState>{
|
|
enablePushNotifications: true,
|
|
enableMailNotifications: true,
|
|
enableLessongsReminders: true,
|
|
enableReleaseAlerts: true,
|
|
preferedLevel: 'easy',
|
|
colorBlind: false,
|
|
micLevel: 50,
|
|
colorScheme: "system"
|
|
},
|
|
},
|
|
reducers: {
|
|
updateSettings: (state, action: PayloadAction<Partial<SettingsState>>) => {
|
|
state.settings = { ...state.settings, ...action.payload };
|
|
}
|
|
}
|
|
});
|
|
export const { updateSettings } = settingsSlice.actions;
|
|
export default settingsSlice.reducer; |