Skip to content

Commit

Permalink
Fix status is added bookmark category statuses list on bottom when bo…
Browse files Browse the repository at this point in the history
…okmark
  • Loading branch information
kmycode committed Sep 24, 2023
1 parent b35fd9f commit b3076e6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/javascript/mastodon/reducers/bookmark_categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ const appendToBookmarkCategoryStatusesById = (state, bookmarkCategoryId, statuse
}));
};

const prependToBookmarkCategoryStatusesById = (state, bookmarkCategoryId, statuses) => {
return state.update(bookmarkCategoryId, listMap => listMap.withMutations(map => {
map.set('isLoading', false);
if (map.get('items')) {
map.update('items', list => ImmutableOrderedSet([statuses]).union(list));
}
}));
};

const removeStatusFromBookmarkCategoryById = (state, bookmarkCategoryId, status) => {
if (state.getIn([bookmarkCategoryId, 'items'])) {
return state.updateIn([bookmarkCategoryId, 'items'], items => items.delete(status));
Expand Down Expand Up @@ -107,7 +116,7 @@ export default function bookmarkCategories(state = initialState, action) {
case BOOKMARK_CATEGORY_STATUSES_EXPAND_SUCCESS:
return appendToBookmarkCategoryStatuses(state, action.id, action.statuses, action.next);
case BOOKMARK_CATEGORY_EDITOR_ADD_SUCCESS:
return appendToBookmarkCategoryStatusesById(state, action.bookmarkCategoryId, action.statusId, undefined);
return prependToBookmarkCategoryStatusesById(state, action.bookmarkCategoryId, action.statusId);
case BOOKMARK_CATEGORY_EDITOR_REMOVE_SUCCESS:
return removeStatusFromBookmarkCategoryById(state, action.bookmarkCategoryId, action.statusId);
case UNBOOKMARK_SUCCESS:
Expand Down

0 comments on commit b3076e6

Please sign in to comment.