session-desktop/ts/state/ducks/userConfig.tsx

38 lines
1.1 KiB
TypeScript
Raw Normal View History

/**
* This slice is intended for the user configurable settings for the client such as appearance, autoplaying of links etc.
* Anything setting under the cog wheel tab.
*/
2021-07-06 06:40:45 +02:00
import { createSlice } from '@reduxjs/toolkit';
export interface UserConfigState {
audioAutoplay: boolean;
2021-08-05 05:15:03 +02:00
showRecoveryPhrasePrompt: boolean;
messageRequests: boolean;
}
export const initialUserConfigState = {
2021-06-24 06:13:45 +02:00
audioAutoplay: false,
2021-08-05 05:15:03 +02:00
showRecoveryPhrasePrompt: true,
messageRequests: true,
};
const userConfigSlice = createSlice({
name: 'userConfig',
initialState: initialUserConfigState,
reducers: {
2021-06-24 06:13:45 +02:00
toggleAudioAutoplay: state => {
state.audioAutoplay = !state.audioAutoplay;
},
2021-08-05 05:15:03 +02:00
disableRecoveryPhrasePrompt: state => {
2021-08-12 01:07:54 +02:00
state.showRecoveryPhrasePrompt = false;
2021-08-05 05:15:03 +02:00
},
toggleMessageRequests: state => {
state.messageRequests = !state.messageRequests;
},
},
2021-06-24 06:13:45 +02:00
});
const { actions, reducer } = userConfigSlice;
export const { toggleAudioAutoplay, disableRecoveryPhrasePrompt, toggleMessageRequests } = actions;
2021-06-24 06:13:45 +02:00
export const userConfigReducer = reducer;