Skip to content

Commit

Permalink
#1518 properly remove tag from list after updating its object
Browse files Browse the repository at this point in the history
  • Loading branch information
matej-vavrek committed Oct 10, 2024
1 parent 238b5c2 commit cdbb897
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion js/reducers/selection/selectionReducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,21 @@ export function selectionReducers(state = INITIAL_STATE, action = {}) {

case constants.REMOVE_FROM_SELECTED_TAG_LIST:
let diminishedSelectedTagList = new Set(state.selectedTagList);
diminishedSelectedTagList.delete(action.item);
// TODO sometimes tag object changes for its updated version
// handle it here or replace it in set in every place of change?
if (diminishedSelectedTagList.has(action.item)) {
diminishedSelectedTagList.delete(action.item);
} else {
let tagToDelete = null;
diminishedSelectedTagList.forEach(tag => {
if (tag.id === action.item.id) {
tagToDelete = tag;
}
});
if (tagToDelete) {
diminishedSelectedTagList.delete(tagToDelete);
}
}
return Object.assign({}, state, { selectedTagList: [...diminishedSelectedTagList] });

case constants.SET_IS_TAG_GLOBAL_EDIT:
Expand Down

0 comments on commit cdbb897

Please sign in to comment.