2021-06-22 09:04:57 +02:00
|
|
|
/**
|
|
|
|
* 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';
|
2021-06-22 09:04:57 +02:00
|
|
|
|
|
|
|
export interface UserConfigState {
|
|
|
|
audioAutoplay: boolean;
|
2021-08-05 05:15:03 +02:00
|
|
|
showRecoveryPhrasePrompt: boolean;
|
2021-10-20 08:49:14 +02:00
|
|
|
messageRequests: boolean;
|
2021-06-22 09:04:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export const initialUserConfigState = {
|
2021-06-24 06:13:45 +02:00
|
|
|
audioAutoplay: false,
|
2021-08-05 05:15:03 +02:00
|
|
|
showRecoveryPhrasePrompt: true,
|
2021-10-20 08:49:14 +02:00
|
|
|
messageRequests: true,
|
2021-06-22 09:04:57 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
const userConfigSlice = createSlice({
|
|
|
|
name: 'userConfig',
|
|
|
|
initialState: initialUserConfigState,
|
|
|
|
reducers: {
|
2021-06-24 06:13:45 +02:00
|
|
|
toggleAudioAutoplay: state => {
|
|
|
|
state.audioAutoplay = !state.audioAutoplay;
|
2021-06-22 09:04:57 +02:00
|
|
|
},
|
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
|
|
|
},
|
2021-11-22 05:48:12 +01:00
|
|
|
toggleMessageRequests: state => {
|
|
|
|
state.messageRequests = !state.messageRequests;
|
2021-10-20 08:49:14 +02:00
|
|
|
},
|
2021-06-22 09:04:57 +02:00
|
|
|
},
|
2021-06-24 06:13:45 +02:00
|
|
|
});
|
2021-06-22 09:04:57 +02:00
|
|
|
|
|
|
|
const { actions, reducer } = userConfigSlice;
|
2021-11-22 05:48:12 +01:00
|
|
|
export const { toggleAudioAutoplay, disableRecoveryPhrasePrompt, toggleMessageRequests } = actions;
|
2021-06-24 06:13:45 +02:00
|
|
|
export const userConfigReducer = reducer;
|