Add bookmarl_category_needed setting
This commit is contained in:
parent
bd0e2bd796
commit
5a961cc368
13 changed files with 66 additions and 8 deletions
|
@ -20,7 +20,14 @@ import {
|
|||
|
||||
const initialState = ImmutableMap();
|
||||
|
||||
const normalizeBookmarkCategory = (state, category) => state.set(category.id, fromJS(category));
|
||||
const normalizeBookmarkCategory = (state, category) => {
|
||||
const old = state.get(category.id);
|
||||
state = state.set(category.id, fromJS(category));
|
||||
if (old) {
|
||||
state = state.setIn([category.id, 'items'], old.get('items'));
|
||||
}
|
||||
return state;
|
||||
};
|
||||
|
||||
const normalizeBookmarkCategories = (state, bookmarkCategories) => {
|
||||
bookmarkCategories.forEach(bookmarkCategory => {
|
||||
|
|
|
@ -9,6 +9,9 @@ import {
|
|||
BOOKMARK_CATEGORY_EDITOR_ADD_SUCCESS,
|
||||
BOOKMARK_CATEGORY_EDITOR_REMOVE_SUCCESS,
|
||||
} from '../actions/bookmark_categories';
|
||||
import {
|
||||
UNBOOKMARK_SUCCESS,
|
||||
} from '../actions/interactions';
|
||||
|
||||
const initialState = ImmutableMap({
|
||||
statusId: null,
|
||||
|
@ -42,6 +45,8 @@ export default function bookmarkCategoryAdderReducer(state = initialState, actio
|
|||
return state.updateIn(['bookmarkCategories', 'items'], bookmarkCategory => bookmarkCategory.unshift(action.bookmarkCategoryId));
|
||||
case BOOKMARK_CATEGORY_EDITOR_REMOVE_SUCCESS:
|
||||
return state.updateIn(['bookmarkCategories', 'items'], bookmarkCategory => bookmarkCategory.filterNot(item => item === action.bookmarkCategoryId));
|
||||
case UNBOOKMARK_SUCCESS:
|
||||
return action.status.get('id') === state.get('statusId') ? state.setIn(['bookmarkCategories', 'items'], ImmutableList()) : state;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue