Skip to content
Extraits de code Groupes Projets
Valider d8a0ee19 rédigé par unarist's avatar unarist Validation de Eugen Rochko
Parcourir les fichiers

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.
parent 91c71471
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -7,12 +7,6 @@ import uuid from '../uuid'; ...@@ -7,12 +7,6 @@ import uuid from '../uuid';
const initialState = Immutable.Map({ const initialState = Immutable.Map({
onboarded: false, onboarded: false,
columns: Immutable.fromJS([
{ id: 'COMPOSE', uuid: uuid(), params: {} },
{ id: 'HOME', uuid: uuid(), params: {} },
{ id: 'NOTIFICATIONS', uuid: uuid(), params: {} },
]),
home: Immutable.Map({ home: Immutable.Map({
shows: Immutable.Map({ shows: Immutable.Map({
reblog: true, reblog: true,
...@@ -60,6 +54,19 @@ const initialState = Immutable.Map({ ...@@ -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 moveColumn = (state, uuid, direction) => {
const columns = state.get('columns'); const columns = state.get('columns');
const index = columns.findIndex(item => item.get('uuid') === uuid); const index = columns.findIndex(item => item.get('uuid') === uuid);
...@@ -76,7 +83,7 @@ const moveColumn = (state, uuid, direction) => { ...@@ -76,7 +83,7 @@ const moveColumn = (state, uuid, direction) => {
export default function settings(state = initialState, action) { export default function settings(state = initialState, action) {
switch(action.type) { switch(action.type) {
case STORE_HYDRATE: case STORE_HYDRATE:
return state.mergeDeep(action.state.get('settings')); return hydrate(action.state.get('settings'));
case SETTING_CHANGE: case SETTING_CHANGE:
return state.setIn(action.key, action.value); return state.setIn(action.key, action.value);
case COLUMN_ADD: case COLUMN_ADD:
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter