Skip to content

TagSpaces is an offline, open source, document manager with tagging support

fixes

Stanimir Marinov4bb9e37def13
diff --git a/app/locales/en/core.json b/app/locales/en/core.json
index 73b2380c0..74439b4ea 100644
--- a/app/locales/en/core.json
+++ b/app/locales/en/core.json
@@ -93,6 +93,7 @@
"useDefaultLocation": "Use default location as a startup location",
"enablingUsingMetaFolder": "Enable the use of a hidden folder(.ts) for storing meta data and thumbnails",
"persistTagsInSidecarFile": "Use sidecar files for saving the tags",
+ "addTagsToLibrary": "Add tags to library",
"useTrashCan": "Move deleted files or folders to trash bin",
"invalidImportFile": "The imported file has invalid format",
"invalidPath": "Invalid Path",
@@ -322,5 +323,6 @@
"persistIndexSwitch": "Switch to manual index creation with persisted search index",
"watchForChangesInLocation": "Watch for external changes in this location",
"proFeature": "feature available in the PRO version",
- "-": "-"
+ "-": "-",
+ "collectedTags": "Collected Tags"
}
diff --git a/app/reducers/tagging-actions.js b/app/reducers/tagging-actions.js
index dcff1ec97..9dc335f64 100644
--- a/app/reducers/tagging-actions.js
+++ b/app/reducers/tagging-actions.js
@@ -17,6 +17,7 @@
* @flow
*/
+import i18n from '../services/i18n';
import { actions as AppActions } from './app';
import { actions as TagLibraryActions, type Tag } from './taglibrary';
import {
@@ -47,7 +48,7 @@ const actions = {
dispatch: (actions: Object) => void,
getState: () => Object
) => {
- const { settings } = getState();
+ const { settings, taglibrary } = getState();
const processedTags = [];
tags.map((pTag) => {
const tag = { ...pTag };
@@ -60,17 +61,27 @@ const actions = {
});
if (settings.addTagsToLibrary) {
- const tagGroup = {
- uuid: 'custom_tag_group_id', // uuid needs to be constant here (see mergeTagGroup)
- title: 'Custom',
- expanded: true,
- color: '#00ff00',
- textcolor: '#000',
- children: processedTags,
- created_date: new Date(),
- modified_date: new Date()
- };
- dispatch(TagLibraryActions.mergeTagGroup(tagGroup));
+ // filter existed in tagLibrary
+ const uniqueTags = [];
+ processedTags.map((tag) => {
+ if (taglibrary.findIndex(tagGroup => tagGroup.children.findIndex(obj => obj.id === tag.id) !== -1) === -1) {
+ uniqueTags.push(tag);
+ }
+ return true;
+ });
+ if (uniqueTags.length > 0) {
+ const tagGroup = {
+ uuid: 'collected_tag_group_id', // uuid needs to be constant here (see mergeTagGroup)
+ title: i18n.t('core:collectedTags'),
+ expanded: true,
+ color: '#00ff00',
+ textcolor: '#000',
+ children: uniqueTags,
+ created_date: new Date(),
+ modified_date: new Date()
+ };
+ dispatch(TagLibraryActions.mergeTagGroup(tagGroup));
+ }
}
// TODO: Handle adding already added tags