Skip to content

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

feature: making tag collection part of the lite app as requested in #1598

Ilian Sapundshiev2f7f75fe17db
diff --git a/app/components/menus/TagGroupMenu.tsx b/app/components/menus/TagGroupMenu.tsx
index 51b8fca11..cbac83b97 100644
--- a/app/components/menus/TagGroupMenu.tsx
+++ b/app/components/menus/TagGroupMenu.tsx
@@ -166,12 +166,7 @@ const TagGroupMenu = (props: Props) => {
<CollectTagsIcon />
</ListItemIcon>
<ListItemText
- primary={
- <>
- {i18n.t('core:collectTagsFromLocation')}
- <ProLabel />
- </>
- }
+ primary={<>{i18n.t('core:collectTagsFromLocation')}</>}
/>
</MenuItem>
</Menu>
diff --git a/app/reducers/tagging-actions.ts b/app/reducers/tagging-actions.ts
index 0081d5c85..4ab590089 100644
--- a/app/reducers/tagging-actions.ts
+++ b/app/reducers/tagging-actions.ts
@@ -739,17 +739,6 @@ const actions = {
) => {
const { settings } = getState();
- if (!Pro || !Pro.Indexer || !Pro.Indexer.collectTagsFromIndex) {
- dispatch(
- AppActions.showNotification(
- i18n.t('core:thisFunctionalityIsAvailableInPro'),
- 'error',
- true
- )
- );
- return true;
- }
-
if (GlobalSearch.index.length < 1) {
dispatch(
AppActions.showNotification(
@@ -761,7 +750,7 @@ const actions = {
return true;
}
- const uniqueTags = Pro.Indexer.collectTagsFromIndex(
+ const uniqueTags = collectTagsFromIndex(
GlobalSearch.index,
tagGroup,
settings
@@ -819,4 +808,35 @@ function generateTagValue(tag) {
return tagTitle;
}
+function collectTagsFromIndex(
+ locationIndex: any,
+ tagGroup: any,
+ settings: any
+) {
+ const uniqueTags = [];
+ const defaultTagColor = settings.tagBackgroundColor;
+ const defaultTagTextColor = settings.tagTextColor;
+ locationIndex.map(entry => {
+ if (entry.tags && entry.tags.length > 0) {
+ entry.tags.map(tag => {
+ if (
+ uniqueTags.findIndex(obj => obj.title === tag.title) < 0 && // element not already added
+ tagGroup.children.findIndex(obj => obj.title === tag.title) < 0 && // element not already added
+ !/^(?:\d+~\d+|\d+)$/.test(tag.title) && // skip adding of tag containing only digits
+ !isGeoTag(tag.title) // skip adding of tag containing geo information
+ ) {
+ uniqueTags.push({
+ ...tag,
+ color: tag.color || defaultTagColor,
+ textcolor: tag.textcolor || defaultTagTextColor
+ });
+ }
+ return true;
+ });
+ }
+ return true;
+ });
+ return uniqueTags;
+}
+
export default actions;