Skip to content

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

Collecting tags in tag group from current location reindex

Stanimir30cb8ecc8510
diff --git a/src/renderer/hooks/TaggingActionsContextProvider.tsx b/src/renderer/hooks/TaggingActionsContextProvider.tsx
index 3c2d6f9c6..b71cd72b7 100644
--- a/src/renderer/hooks/TaggingActionsContextProvider.tsx
+++ b/src/renderer/hooks/TaggingActionsContextProvider.tsx
@@ -60,6 +60,7 @@ import { useEditedTagLibraryContext } from '-/hooks/useEditedTagLibraryContext';
import { CommonLocation } from '-/utils/CommonLocation';
import LoadingLazy from '-/components/LoadingLazy';
import { getAllTags } from '-/services/utils-io';
+import ConfirmDialog from '-/components/dialogs/ConfirmDialog';
type TaggingActionsContextData = {
addTagsToFsEntries: (
@@ -201,7 +202,7 @@ export const TaggingActionsContextProvider = ({
} = useTagGroupsLocationContext();
const { currentDirectoryEntries, getAllPropertiesPromise, getMetaForEntry } =
useDirectoryContentContext();
- const { getIndex } = useLocationIndexContext();
+ const { getIndex, createLocationIndex } = useLocationIndexContext();
const { renameFile, saveMetaDataPromise, saveCurrentLocationMetaData } =
useIOActionsContext();
const { reflectUpdateMeta, setReflectActions } = useEditedEntryContext();
@@ -213,6 +214,8 @@ export const TaggingActionsContextProvider = ({
entries?: TS.FileSystemEntry[];
}>({ open: false });
+ const [isConfirmReindexDialogOpened, setConfirmReindexDialogOpened] =
+ useState<TS.TagGroup>(undefined);
const geoTaggingFormat = useSelector(getGeoTaggingFormat);
const maxCollectedTag = useSelector(getMaxCollectedTag);
const addTagsToLibrary = useSelector(getAddTagsToLibrary);
@@ -975,7 +978,9 @@ export const TaggingActionsContextProvider = ({
function collectTagsFromLocation(tagGroup: TS.TagGroup) {
const index = getIndex();
if (!index || index.length < 1) {
- showNotification('Please index location first', 'error', true);
+ //open confirm
+ setConfirmReindexDialogOpened(tagGroup);
+ //showNotification('Please index location first', 'error', true);
return true;
}
@@ -1540,6 +1545,28 @@ export const TaggingActionsContextProvider = ({
entries={dialogState.entries}
/>
)}
+ {isConfirmReindexDialogOpened && (
+ <ConfirmDialog
+ open={Boolean(isConfirmReindexDialogOpened)}
+ onClose={() => {
+ setConfirmReindexDialogOpened(undefined);
+ }}
+ title={t('core:confirmReindex')}
+ content={t('core:confirmReindexContent')}
+ confirmCallback={(result) => {
+ if (result) {
+ createLocationIndex(currentLocation).then(() =>
+ collectTagsFromLocation(isConfirmReindexDialogOpened),
+ );
+ } else {
+ setConfirmReindexDialogOpened(undefined);
+ }
+ }}
+ cancelDialogTID="cancelConfirmReindexDialog"
+ confirmDialogTID="confirmConfirmReindexDialog"
+ confirmDialogContentTID="confirConfirmReindexDialogContent"
+ />
+ )}
{children}
</TaggingActionsContext.Provider>
diff --git a/src/renderer/locales/en/core.json b/src/renderer/locales/en/core.json
index b464807f5..7703e4580 100644
--- a/src/renderer/locales/en/core.json
+++ b/src/renderer/locales/en/core.json
@@ -971,5 +971,7 @@
"transferMeta": "Transfer Sidecar Files",
"transferMetaInfo": "Transfer corresponding thumbnails and sidecar files containing tags or description",
"renameDisableTooltip": "Exit the file edit mode in order to rename it",
+ "confirmReindex": "Index not available",
+ "confirmReindexContent": "Do you want to create it now?",
"-": "-"
}