const initialState = Immutable.Map({
onboarded: false,
- columns: Immutable.fromJS([
- { id: 'COMPOSE', uuid: uuid(), params: {} },
- { id: 'HOME', uuid: uuid(), params: {} },
- { id: 'NOTIFICATIONS', uuid: uuid(), params: {} },
- ]),
-
home: Immutable.Map({
shows: Immutable.Map({
reblog: true,
}),
});
+const defaultColumns = Immutable.fromJS([
+ { id: 'COMPOSE', uuid: uuid(), params: {} },
+ { id: 'HOME', uuid: uuid(), params: {} },
+ { id: 'NOTIFICATIONS', uuid: uuid(), params: {} },
+]);
+
+const hydrate = (settings) => {
+ return initialState.withMutations((state) => {
+ state.mergeDeep(settings);
+ state.update('columns', defaultColumns, val => val);
+ });
+};
+
const moveColumn = (state, uuid, direction) => {
const columns = state.get('columns');
const index = columns.findIndex(item => item.get('uuid') === uuid);
export default function settings(state = initialState, action) {
switch(action.type) {
case STORE_HYDRATE:
- return state.mergeDeep(action.state.get('settings'));
+ return hydrate(action.state.get('settings'));
case SETTING_CHANGE:
return state.setIn(action.key, action.value);
case COLUMN_ADD: