|
|
|
@ -2,6 +2,7 @@ import { SETTING_CHANGE, SETTING_SAVE } from 'flavours/glitch/actions/settings';
|
|
|
|
|
import { COLUMN_ADD, COLUMN_REMOVE, COLUMN_MOVE } from 'flavours/glitch/actions/columns';
|
|
|
|
|
import { STORE_HYDRATE } from 'flavours/glitch/actions/store';
|
|
|
|
|
import { EMOJI_USE } from 'flavours/glitch/actions/emojis';
|
|
|
|
|
import { LIST_DELETE_SUCCESS, LIST_FETCH_FAIL } from '../actions/lists';
|
|
|
|
|
import { Map as ImmutableMap, fromJS } from 'immutable';
|
|
|
|
|
import uuid from 'flavours/glitch/util/uuid';
|
|
|
|
|
|
|
|
|
@ -92,6 +93,8 @@ const moveColumn = (state, uuid, direction) => {
|
|
|
|
|
|
|
|
|
|
const updateFrequentEmojis = (state, emoji) => state.update('frequentlyUsedEmojis', ImmutableMap(), map => map.update(emoji.id, 0, count => count + 1)).set('saved', false);
|
|
|
|
|
|
|
|
|
|
const filterDeadListColumns = (state, listId) => state.update('columns', columns => columns.filterNot(column => column.get('id') === 'LIST' && column.get('params').get('id') === listId));
|
|
|
|
|
|
|
|
|
|
export default function settings(state = initialState, action) {
|
|
|
|
|
switch(action.type) {
|
|
|
|
|
case STORE_HYDRATE:
|
|
|
|
@ -114,6 +117,10 @@ export default function settings(state = initialState, action) {
|
|
|
|
|
return updateFrequentEmojis(state, action.emoji);
|
|
|
|
|
case SETTING_SAVE:
|
|
|
|
|
return state.set('saved', true);
|
|
|
|
|
case LIST_FETCH_FAIL:
|
|
|
|
|
return action.error.response.status === 404 ? filterDeadListColumns(state, action.id) : state;
|
|
|
|
|
case LIST_DELETE_SUCCESS:
|
|
|
|
|
return filterDeadListColumns(state, action.id);
|
|
|
|
|
default:
|
|
|
|
|
return state;
|
|
|
|
|
}
|
|
|
|
|