TagSpaces is an offline, open source, document manager with tagging support
fixing tag moving bug in tag library
Ilian Sapundshieve5e366b035a5
diff --git a/app/reducers/taglibrary.js b/app/reducers/taglibrary.jsindex d43f8c84f..eb74e886b 100644--- a/app/reducers/taglibrary.js+++ b/app/reducers/taglibrary.js@@ -336,22 +336,22 @@ export default (state: Array<TagGroup> = defaultTagLibrary, action: Object) => {if (tagGroup.uuid === action.toTagGroupId) {indexToGroup = index;}- if (tagGroup.children) {- tagGroup.children.forEach((tag, tagIndex) => {- if (tag.id === action.tagID) {- tagIndexForRemoving = tagIndex;- }- return true;- });- }});+ if (indexFromGroup >= 0 && state[indexFromGroup].children) {+ state[indexFromGroup].children.forEach((tag, tagIndex) => {+ if (tag.id === action.tagID) {+ tagIndexForRemoving = tagIndex;+ }+ return true;+ });+ }if (indexToGroup >= 0 && indexToGroup >= 0 && tagIndexForRemoving >= 0) {const newTagLibrary = [...state];const tag = { ...state[indexFromGroup].children[tagIndexForRemoving] };newTagLibrary[indexToGroup].children.push(tag);newTagLibrary[indexFromGroup].children = [- ...newTagLibrary[indexFromGroup].children.splice(0, tagIndexForRemoving),- ...newTagLibrary[indexFromGroup].children.splice(tagIndexForRemoving + 1)+ ...newTagLibrary[indexFromGroup].children.slice(0, tagIndexForRemoving),+ ...newTagLibrary[indexFromGroup].children.slice(tagIndexForRemoving + 1)];return newTagLibrary;}