mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-10-31 22:40:01 +00:00
Account.source default values
This commit is contained in:
parent
45c4c1fa3f
commit
23ff2f1568
1 changed files with 10 additions and 7 deletions
|
@ -18,8 +18,9 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const {createSlice} = require("@reduxjs/toolkit");
|
||||
const { createSlice } = require("@reduxjs/toolkit");
|
||||
const d = require("dotty");
|
||||
const defaultValue = require("default-value");
|
||||
|
||||
module.exports = createSlice({
|
||||
name: "user",
|
||||
|
@ -28,20 +29,22 @@ module.exports = createSlice({
|
|||
settings: {}
|
||||
},
|
||||
reducers: {
|
||||
setAccount: (state, {payload}) => {
|
||||
if (payload.source != undefined && payload.source.language != undefined) {
|
||||
payload.source.language = payload.source.language.toUpperCase();
|
||||
}
|
||||
setAccount: (state, { payload }) => {
|
||||
payload.source = defaultValue(payload.source, {});
|
||||
payload.source.language = defaultValue(payload.source.language.toUpperCase(), "EN");
|
||||
payload.source.status_format = defaultValue(payload.source.status_format, "plain");
|
||||
payload.source.sensitive = defaultValue(payload.source.sensitive, false);
|
||||
|
||||
state.profile = payload;
|
||||
// /user/settings only needs a copy of the 'source' obj
|
||||
state.settings = {
|
||||
source: payload.source
|
||||
};
|
||||
},
|
||||
setProfileVal: (state, {payload: [key, val]}) => {
|
||||
setProfileVal: (state, { payload: [key, val] }) => {
|
||||
d.put(state.profile, key, val);
|
||||
},
|
||||
setSettingsVal: (state, {payload: [key, val]}) => {
|
||||
setSettingsVal: (state, { payload: [key, val] }) => {
|
||||
d.put(state.settings, key, val);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue