diff options
author | unarist <m.unarist@gmail.com> | 2017-06-15 04:59:52 +0900 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-06-14 21:59:52 +0200 |
commit | d8a0ee1956e291e88a33425eb504d36c85fc3a3f (patch) | |
tree | 9feae6039eea5286394346cfdb0fe96e15c7bc65 /app/javascript | |
parent | 91c71471ab41bb9af673daf6dde50159d0bfde18 (diff) |
Fix merge default columns (#3748)
mergeDeep also merges columns, but it should be replaced simply. So in the new function, first apply mergeDeep except columns, and set default columns if columns unset.
Diffstat (limited to 'app/javascript')
-rw-r--r-- | app/javascript/mastodon/reducers/settings.js | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/app/javascript/mastodon/reducers/settings.js b/app/javascript/mastodon/reducers/settings.js index 3dc885fab..35698ef82 100644 --- a/app/javascript/mastodon/reducers/settings.js +++ b/app/javascript/mastodon/reducers/settings.js @@ -7,12 +7,6 @@ import uuid from '../uuid'; 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, @@ -60,6 +54,19 @@ const initialState = Immutable.Map({ }), }); +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); @@ -76,7 +83,7 @@ const moveColumn = (state, uuid, direction) => { 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: |