Skip to content

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

fix add-remove many tags (#2010)

Stanimir8ba1b660454e
diff --git a/app/components/TagContainerMenu.tsx b/app/components/TagContainerMenu.tsx
index 09d5e4129..ace2a9d42 100644
--- a/app/components/TagContainerMenu.tsx
+++ b/app/components/TagContainerMenu.tsx
@@ -44,7 +44,9 @@ function TagContainerMenu(props: Props) {
color: tag.textcolor,
fontSize: 20,
}}
- onClick={(event) => handleRemoveTag(event, [tag])}
+ onClick={(event) =>
+ handleRemoveTag ? handleRemoveTag(event, [tag]) : false
+ }
/>
)
) : (
diff --git a/app/hooks/DirectoryContentContextProvider.tsx b/app/hooks/DirectoryContentContextProvider.tsx
index e250e47a1..c3a349dde 100644
--- a/app/hooks/DirectoryContentContextProvider.tsx
+++ b/app/hooks/DirectoryContentContextProvider.tsx
@@ -44,7 +44,12 @@ import {
getMetaDirectoryPath,
} from '@tagspaces/tagspaces-common/paths';
import PlatformIO from '-/services/platform-facade';
-import { loadJSONFile, merge, updateFsEntries } from '-/services/utils-io';
+import {
+ getMetaForEntry,
+ loadJSONFile,
+ merge,
+ updateFsEntries,
+} from '-/services/utils-io';
import AppConfig from '-/AppConfig';
import { PerspectiveIDs } from '-/perspectives';
import { updateHistory } from '-/utils/dom';
@@ -83,6 +88,7 @@ type DirectoryContentContextData = {
isSearchMode: boolean;
addDirectoryEntries: (entries: TS.FileSystemEntry[]) => void;
removeDirectoryEntries: (entryPaths: string[]) => void;
+ reflectRenameEntries: (paths: Array<string[]>) => Promise<boolean>;
setSearchQuery: (sQuery: TS.SearchQuery) => void;
loadParentDirectoryContent: () => void;
loadDirectoryContent: (
@@ -133,6 +139,7 @@ export const DirectoryContentContext =
isSearchMode: false,
addDirectoryEntries: undefined,
removeDirectoryEntries: undefined,
+ reflectRenameEntries: undefined,
setSearchQuery: () => {},
loadParentDirectoryContent: () => {},
loadDirectoryContent: undefined,
@@ -219,7 +226,7 @@ export const DirectoryContentContextProvider = ({
/**
* HANDLE REFLECT_RENAME_ENTRY
*/
- useEffect(() => {
+ /*useEffect(() => {
if (!firstRender && editedEntryPaths && editedEntryPaths.length > 0) {
let action;
for (const editedEntryPath of editedEntryPaths) {
@@ -255,23 +262,79 @@ export const DirectoryContentContextProvider = ({
const newDirectoryEntries = currentDirectoryEntries.map((entry) =>
entry.path === oldFilePath ? newEntry : entry,
);
- /*if (searchMode.current) {
+ /!*if (searchMode.current) {
GlobalSearch.getInstance().setResults(newDirectoryEntries);
- } else {*/
+ } else {*!/
setCurrentDirectoryEntries(newDirectoryEntries);
// setSelectedEntries newEntry to scroll into it
setSelectedEntries([newEntry]);
//}
}
- } /*else if (action === 'delete') {
- const filePath = editedEntryPaths[0].path;
- const newDirectoryEntries = currentDirectoryEntries.filter(
- entry => entry.path !== filePath
- );
+ }
+ }
+ }, [editedEntryPaths]);*/
+
+ const reflectRenameEntries = useMemo(() => {
+ return (paths: Array<string[]>): Promise<boolean> => {
+ const metaChanged = [];
+ const newEntries = paths
+ .map((path) => {
+ const entry = currentDirectoryEntries.find((e) => e.path === path[0]);
+ if (path[0] === path[1]) {
+ metaChanged.push(entry);
+ return undefined;
+ }
+ return getNewEntry(entry, path[1]);
+ })
+ .filter((item) => item !== undefined);
+ if (newEntries.length > 0) {
+ const newDirectoryEntries = currentDirectoryEntries.map((entry) => {
+ const newEntry = newEntries.find(
+ (nEntry) => nEntry && nEntry.uuid === entry.uuid,
+ );
+ if (newEntry) {
+ return newEntry;
+ }
+ return entry;
+ });
setCurrentDirectoryEntries(newDirectoryEntries);
- }*/
+ setSelectedEntries(newEntries);
+ }
+
+ if (metaChanged.length > 0) {
+ const enhancedEntriesPromises = metaChanged.map((entry) =>
+ getMetaForEntry(entry),
+ );
+ Promise.all(enhancedEntriesPromises).then((entries) => {
+ updateCurrentDirEntries(entries);
+ });
+ }
+ return Promise.resolve(true);
+ };
+ }, [currentDirectoryEntries]);
+
+ function getNewEntry(entry: TS.FileSystemEntry, newPath): TS.FileSystemEntry {
+ if (entry) {
+ const fileNameTags = entry.isFile
+ ? extractTagsAsObjects(
+ newPath,
+ AppConfig.tagDelimiter,
+ PlatformIO.getDirSeparator(),
+ )
+ : []; // dirs dont have tags in filename
+ return {
+ ...entry,
+ path: newPath,
+ name: extractFileName(newPath, PlatformIO.getDirSeparator()),
+ extension: extractFileExtension(newPath, PlatformIO.getDirSeparator()),
+ tags: [
+ ...entry.tags.filter((tag) => tag.type !== 'plain'), //'sidecar'), // add only sidecar tags
+ ...fileNameTags,
+ ],
+ };
}
- }, [editedEntryPaths]);
+ return undefined;
+ }
function exitSearchMode() {
isSearchMode.current = false;
@@ -358,7 +421,7 @@ export const DirectoryContentContextProvider = ({
(prevValue, currentValue) =>
merge(currentValue, prevValue) as TS.FileSystemEntry,
);
- return merge(updatedEntry, currentEntry);
+ return merge(updatedEntry, { ...currentEntry, tags: [] });
}
return currentEntry;
});
@@ -810,6 +873,7 @@ export const DirectoryContentContextProvider = ({
setCurrentDirectoryFiles,
addDirectoryEntries,
removeDirectoryEntries,
+ reflectRenameEntries,
updateCurrentDirEntries,
updateThumbnailUrl,
setDirectoryMeta,
diff --git a/app/hooks/FsActionsContextProvider.tsx b/app/hooks/FsActionsContextProvider.tsx
index b451159bc..46ce8f2d8 100644
--- a/app/hooks/FsActionsContextProvider.tsx
+++ b/app/hooks/FsActionsContextProvider.tsx
@@ -26,7 +26,6 @@ import {
getMetaFileLocationForFile,
getThumbFileLocationForFile,
} from '@tagspaces/tagspaces-common/paths';
-import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';
import { getWarningOpeningFilesExternally } from '-/reducers/settings';
import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
import { useNotificationContext } from '-/hooks/useNotificationContext';
@@ -40,7 +39,11 @@ type FsActionsContextData = {
directoryPath: string,
newDirectoryName: string,
) => Promise<string>;
- renameFile: (filePath: string, newFilePath: string) => Promise<boolean>;
+ renameFile: (
+ filePath: string,
+ newFilePath: string,
+ reflect?: boolean,
+ ) => Promise<boolean>;
openFileNatively: (selectedFile?: string) => void;
};
@@ -59,8 +62,8 @@ export const FsActionsContextProvider = ({
}: FsActionsContextProviderProps) => {
const { t } = useTranslation();
const { setSelectedEntries, selectedEntries } = useSelectedEntriesContext();
- const { openedEntries, reflectRenameOpenedEntry } = useOpenedEntryContext();
- const { openDirectory, currentDirectoryPath } = useDirectoryContentContext();
+ const { openDirectory, currentDirectoryPath, reflectRenameEntries } =
+ useDirectoryContentContext();
const { reflectRenameEntry } = useLocationIndexContext();
const { showNotification } = useNotificationContext();
const { watcher } = useFSWatcherContext();
@@ -71,112 +74,143 @@ export const FsActionsContextProvider = ({
getWarningOpeningFilesExternally,
);
- function renameDirectory(directoryPath: string, newDirectoryName: string) {
- return renameDirectoryPromise(directoryPath, newDirectoryName)
- .then((newDirPath) => {
- if (currentDirectoryPath === directoryPath) {
- openDirectory(newDirPath).then(() => {
- reflectRenameOpenedEntry(directoryPath, newDirPath);
- reflectRenameEntry(directoryPath, newDirPath);
- });
- } else {
- reflectRenameEntry(directoryPath, newDirPath);
- dispatch(AppActions.reflectRenameEntry(directoryPath, newDirPath));
- }
- setSelectedEntries([]);
-
- showNotification(
- `Renaming directory ${extractDirectoryName(
- directoryPath,
- PlatformIO.getDirSeparator(),
- )} successful.`,
- 'default',
- true,
- );
- return newDirPath;
- })
- .catch((error) => {
- console.warn('Error while renaming directory: ' + error);
- showNotification(
- `Error renaming directory '${extractDirectoryName(
- directoryPath,
- PlatformIO.getDirSeparator(),
- )}'`,
- 'error',
- true,
- );
- throw error;
- });
- }
+ const renameDirectory = useMemo(() => {
+ return (directoryPath: string, newDirectoryName: string): Promise<string> =>
+ renameDirectoryPromise(directoryPath, newDirectoryName)
+ .then((newDirPath) => {
+ if (currentDirectoryPath === directoryPath) {
+ openDirectory(newDirPath).then(() => {
+ //reflectRenameOpenedEntry(directoryPath, newDirPath);
+ reflectRenameEntry(directoryPath, newDirPath);
+ });
+ } else {
+ reflectRenameEntries([[directoryPath, newDirPath]]).then(() => {
+ reflectRenameEntry(directoryPath, newDirPath);
+ dispatch(
+ AppActions.reflectRenameEntry(directoryPath, newDirPath),
+ );
+ });
+ }
+ setSelectedEntries([]);
- function renameFile(filePath: string, newFilePath: string): Promise<boolean> {
- return renameFilePromise(filePath, newFilePath)
- .then((result) => {
- const newFilePathFromPromise = result[1];
- console.info('File renamed ' + filePath + ' to ' + newFilePath);
- showNotification(t('core:renamingSuccessfully'), 'default', true);
- // Update sidecar file and thumb
- return renameFilesPromise([
- [
- getMetaFileLocationForFile(filePath, PlatformIO.getDirSeparator()),
- getMetaFileLocationForFile(
- newFilePath,
+ showNotification(
+ `Renaming directory ${extractDirectoryName(
+ directoryPath,
PlatformIO.getDirSeparator(),
- ),
- ],
- [
- getThumbFileLocationForFile(
- filePath,
+ )} successful.`,
+ 'default',
+ true,
+ );
+ return newDirPath;
+ })
+ .catch((error) => {
+ console.warn('Error while renaming directory: ' + error);
+ showNotification(
+ `Error renaming directory '${extractDirectoryName(
+ directoryPath,
PlatformIO.getDirSeparator(),
- false,
- ),
- getThumbFileLocationForFile(
- newFilePath,
- PlatformIO.getDirSeparator(),
- false,
- ),
- ],
- ])
- .then(() => {
- reflectRenameEntry(filePath, newFilePathFromPromise);
- dispatch(
- AppActions.reflectRenameEntry(filePath, newFilePathFromPromise),
- );
- // setSelectedEntries([]);
- console.info(
- 'Renaming meta file and thumb successful from ' +
- filePath +
- ' to:' +
+ )}'`,
+ 'error',
+ true,
+ );
+ throw error;
+ });
+ }, [reflectRenameEntries]);
+
+ const renameFile = useMemo(() => {
+ return (
+ filePath: string,
+ newFilePath: string,
+ reflect: boolean = true,
+ ): Promise<boolean> =>
+ renameFilePromise(filePath, newFilePath)
+ .then((result) => {
+ const newFilePathFromPromise = result[1];
+ console.info('File renamed ' + filePath + ' to ' + newFilePath);
+ showNotification(t('core:renamingSuccessfully'), 'default', true);
+ // Update sidecar file and thumb
+ return renameFilesPromise([
+ [
+ getMetaFileLocationForFile(
+ filePath,
+ PlatformIO.getDirSeparator(),
+ ),
+ getMetaFileLocationForFile(
newFilePath,
- );
- return true;
- })
- .catch((err) => {
- reflectRenameEntry(filePath, newFilePathFromPromise);
- dispatch(
- AppActions.reflectRenameEntry(filePath, newFilePathFromPromise),
- );
- setSelectedEntries([]);
- console.warn(
- 'Renaming meta file and thumb failed from ' +
- filePath +
- ' to:' +
+ PlatformIO.getDirSeparator(),
+ ),
+ ],
+ [
+ getThumbFileLocationForFile(
+ filePath,
+ PlatformIO.getDirSeparator(),
+ false,
+ ),
+ getThumbFileLocationForFile(
newFilePath,
- err,
- );
- return false;
- });
- })
- .catch((error) => {
- console.log(`Error while renaming file ${filePath}`, error);
- showNotification(
- `Error while renaming file ${filePath}`,
- 'error',
- true,
- );
- return false;
- });
- }
+ PlatformIO.getDirSeparator(),
+ false,
+ ),
+ ],
+ ])
+ .then(() => {
+ if (reflect) {
+ reflectRenameEntries([[filePath, newFilePathFromPromise]]).then(
+ () => {
+ reflectRenameEntry(filePath, newFilePathFromPromise);
+ dispatch(
+ AppActions.reflectRenameEntry(
+ filePath,
+ newFilePathFromPromise,
+ ),
+ );
+ },
+ );
+ }
+ // setSelectedEntries([]);
+ console.info(
+ 'Renaming meta file and thumb successful from ' +
+ filePath +
+ ' to:' +
+ newFilePath,
+ );
+ return true;
+ })
+ .catch((err) => {
+ if (reflect) {
+ reflectRenameEntries([[filePath, newFilePathFromPromise]]).then(
+ () => {
+ reflectRenameEntry(filePath, newFilePathFromPromise);
+ dispatch(
+ AppActions.reflectRenameEntry(
+ filePath,
+ newFilePathFromPromise,
+ ),
+ );
+ },
+ );
+ }
+ // setSelectedEntries([]);
+ console.warn(
+ 'Renaming meta file and thumb failed from ' +
+ filePath +
+ ' to:' +
+ newFilePath,
+ err,
+ );
+ return false;
+ });
+ })
+ .catch((error) => {
+ console.log(`Error while renaming file ${filePath}`, error);
+ showNotification(
+ `Error while renaming file ${filePath}`,
+ 'error',
+ true,
+ );
+ return false;
+ });
+ }, [reflectRenameEntries]);
function openFileNatively(selectedFile?: string) {
// todo reload selectedEntries or find better place for this function
@@ -200,7 +234,7 @@ export const FsActionsContextProvider = ({
renameFile,
openFileNatively,
};
- }, [openedEntries, watcher]);
+ }, [renameDirectory, renameFile, watcher]);
return (
<FsActionsContext.Provider value={context}>
diff --git a/app/hooks/OpenedEntryContextProvider.tsx b/app/hooks/OpenedEntryContextProvider.tsx
index 9d9e46fb6..25929a594 100644
--- a/app/hooks/OpenedEntryContextProvider.tsx
+++ b/app/hooks/OpenedEntryContextProvider.tsx
@@ -105,7 +105,11 @@ type OpenedEntryContextData = {
fileType: 'md' | 'txt' | 'html',
) => void;
createFile: () => void;
- reflectRenameOpenedEntry: (entryPath: string, newEntryPath: string) => void;
+ reflectRenameOpenedEntry: (
+ entryPath: string,
+ newEntryPath: string,
+ reload?: boolean,
+ ) => void;
reflectDeleteDirectory: (directoryPath: string) => void;
reflectDeleteFile: (filePath: string) => void;
};
@@ -982,13 +986,17 @@ export const OpenedEntryContextProvider = ({
});
}
- function reflectRenameOpenedEntry(entryPath, newEntryPath) {
+ function reflectRenameOpenedEntry(entryPath, newEntryPath, reload = false) {
if (openedEntries && openedEntries.length > 0) {
if (openedEntries[0].path === entryPath) {
if (currentLocation) {
updateHistory(currentLocation, currentDirectoryPath, newEntryPath);
}
- addToEntryContainer({ ...openedEntries[0], path: newEntryPath });
+ if (reload) {
+ openEntry(newEntryPath);
+ } else {
+ addToEntryContainer({ ...openedEntries[0], path: newEntryPath });
+ }
}
}
}
diff --git a/app/hooks/PaginationContextProvider.tsx b/app/hooks/PaginationContextProvider.tsx
index 75c26401e..19898ed61 100644
--- a/app/hooks/PaginationContextProvider.tsx
+++ b/app/hooks/PaginationContextProvider.tsx
@@ -21,7 +21,6 @@ import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
import { defaultSettings } from '-/perspectives/grid-perspective';
import { useSortedDirContext } from '-/perspectives/grid-perspective/hooks/useSortedDirContext';
import { TS } from '-/tagspaces.namespace';
-import { loadCurrentDirMeta } from '-/services/meta-loader';
type PaginationContextData = {
page: number;
@@ -43,11 +42,7 @@ export const PaginationContextProvider = ({
children,
}: PaginationContextProviderProps) => {
const initPage = 1;
- const {
- currentDirectoryPath,
- currentDirectoryEntries,
- updateCurrentDirEntries,
- } = useDirectoryContentContext();
+ const { currentDirectoryPath } = useDirectoryContentContext();
const { settings, sortedDirContent } = useSortedDirContext();
const [page, setPage] = useState<number>(initPage);
diff --git a/app/hooks/TaggingActionsContextProvider.tsx b/app/hooks/TaggingActionsContextProvider.tsx
index d8b38f980..017df6c7f 100644
--- a/app/hooks/TaggingActionsContextProvider.tsx
+++ b/app/hooks/TaggingActionsContextProvider.tsx
@@ -67,20 +67,23 @@ type TaggingActionsContextData = {
path: string,
tags: Array<TS.Tag>,
updateIndex?: boolean,
- ) => Promise<boolean>;
+ ) => Promise<string[]>;
editTagForEntry: (path: string, tag: TS.Tag, newTagTitle?: string) => void;
removeTags: (paths: Array<string>, tags?: Array<TS.Tag>) => Promise<boolean>;
- removeTagsFromEntry: (path: string, tags?: Array<TS.Tag>) => Promise<boolean>;
+ removeTagsFromEntry: (
+ path: string,
+ tags?: Array<TS.Tag>,
+ ) => Promise<string[]>;
removeAllTags: (paths: Array<string>) => Promise<boolean>;
collectTagsFromLocation: (tagGroup: TS.TagGroup) => void;
};
export const TaggingActionsContext = createContext<TaggingActionsContextData>({
- addTags: () => Promise.resolve(false),
- addTagsToEntry: () => Promise.resolve(false),
+ addTags: undefined,
+ addTagsToEntry: undefined,
editTagForEntry: () => {},
removeTags: () => Promise.resolve(false),
- removeTagsFromEntry: () => Promise.resolve(false),
+ removeTagsFromEntry: undefined,
removeAllTags: () => Promise.resolve(false),
collectTagsFromLocation: () => {},
});
@@ -93,8 +96,10 @@ export const TaggingActionsContextProvider = ({
children,
}: TaggingActionsContextProviderProps) => {
const { t } = useTranslation();
- const { openedEntries, updateOpenedFile } = useOpenedEntryContext();
- const { updateCurrentDirEntry } = useDirectoryContentContext();
+ const { openedEntries, updateOpenedFile, reflectRenameOpenedEntry } =
+ useOpenedEntryContext();
+ const { updateCurrentDirEntry, reflectRenameEntries } =
+ useDirectoryContentContext();
const { persistTagsInSidecarFile } = useCurrentLocationContext();
const { getIndex, indexUpdateSidecarTags } = useLocationIndexContext();
const { renameFile } = useFsActionsContext();
@@ -167,7 +172,7 @@ export const TaggingActionsContextProvider = ({
if (processedTags.length > 0) {
const promises = paths.map((path) =>
- addTagsToEntry(path, processedTags, updateIndex),
+ addTagsToEntry(path, processedTags, updateIndex, false),
);
if (addTagsToLibrary) {
@@ -207,7 +212,10 @@ export const TaggingActionsContextProvider = ({
dispatch(AppActions.tagLibraryChanged());
}
}
- return Promise.all(promises).then(() => true);
+ return Promise.all(promises).then((editedPaths) => {
+ return reflectRenameEntries(editedPaths);
+ //return openCurrentDirectory();
+ });
}
return Promise.resolve(false);
}
@@ -254,11 +262,19 @@ export const TaggingActionsContextProvider = ({
return tagTitle;
}
+ /**
+ * @param path
+ * @param tags
+ * @param updateIndex
+ * @param reflect
+ * return [oldPath, newPath]
+ */
async function addTagsToEntry(
path: string,
tags: Array<TS.Tag>,
updateIndex = true,
- ): Promise<boolean> {
+ reflect: boolean = true,
+ ): Promise<string[]> {
const entryProperties = await PlatformIO.getPropertiesPromise(path);
let fsEntryMeta;
try {
@@ -291,7 +307,7 @@ export const TaggingActionsContextProvider = ({
id: 'opened_entry_id',
tags: newTags,
});
- return true;
+ return [path, path];
})
.catch((err) => {
console.warn('Error adding tags for ' + path + ' with ' + err);
@@ -300,7 +316,7 @@ export const TaggingActionsContextProvider = ({
'error',
true,
);
- return false;
+ return [path, path];
});
}
} else {
@@ -309,7 +325,10 @@ export const TaggingActionsContextProvider = ({
.then(() => {
// TODO rethink this updateCurrentDirEntry and not need for KanBan
reflectUpdateSidecarTags(path, tags, updateIndex);
- return updateOpenedFile(path, { id: '', tags }); //, changed: true });
+ return updateOpenedFile(path, { id: '', tags }).then(() => [
+ path,
+ path,
+ ]);
})
.catch((error) => {
console.warn('Error adding tags for ' + path + ' with ' + error);
@@ -318,7 +337,7 @@ export const TaggingActionsContextProvider = ({
'error',
true,
);
- return true;
+ return [path, path];
});
}
} else if (fsEntryMeta) {
@@ -353,7 +372,10 @@ export const TaggingActionsContextProvider = ({
tagDelimiter,
prefixTagContainer,
);
- return renameFile(path, newFilePath);
+ return renameFile(path, newFilePath, reflect).then(() => {
+ reflectRenameOpenedEntry(path, newFilePath);
+ return [path, newFilePath];
+ });
}
} else {
// Handling tags in filename by no sidecar
@@ -385,10 +407,13 @@ export const TaggingActionsContextProvider = ({
prefixTagContainer,
);
if (path !== newFilePath) {
- return renameFile(path, newFilePath);
+ return renameFile(path, newFilePath, reflect).then(() => {
+ reflectRenameOpenedEntry(path, newFilePath);
+ return [path, newFilePath];
+ });
}
}
- return Promise.resolve(false);
+ return Promise.resolve([path, path]);
function getNonExistingTags(
newTagsArray: Array<TS.Tag>,
@@ -611,18 +636,24 @@ export const TaggingActionsContextProvider = ({
paths: Array<string>,
tags?: Array<TS.Tag>,
): Promise<boolean> {
- const promises = paths.map((path) => removeTagsFromEntry(path, tags));
- return Promise.all(promises).then(() => true);
+ const promises = paths.map((path) =>
+ removeTagsFromEntry(path, tags, false),
+ );
+ return Promise.all(promises).then((editedPaths) => {
+ return reflectRenameEntries(editedPaths);
+ });
}
/**
* @param path
* @param tags? if undefined will remove all tags
+ * @param reflect
*/
function removeTagsFromEntry(
path: string,
tags?: Array<TS.Tag>,
- ): Promise<boolean> {
+ reflect: boolean = true,
+ ): Promise<string[]> {
const tagTitlesForRemoving = tags
? tags.map((tag) => tag.title)
: undefined;
@@ -642,10 +673,12 @@ export const TaggingActionsContextProvider = ({
newFilePath,
).then(() => {
// dispatch(AppActions.reflectEditedEntryPaths([newFilePath]));
- return updateOpenedFile(path, {
+ reflectRenameOpenedEntry(path, newFilePath, true);
+ /*return updateOpenedFile(newFilePath, {
id: '',
tags: newTags,
- });
+ }).then(() => [path, newFilePath]);*/
+ return [path, newFilePath];
});
},
);
@@ -653,7 +686,10 @@ export const TaggingActionsContextProvider = ({
.catch((error) => {
console.warn('Error removing tags for ' + path + ' with ' + error);
// dispatch(AppActions.showNotification(t('core:removingSidecarTagsFailed'), 'error', true));
- return removeTagsFromFilename().then(() => true);
+ return removeTagsFromFilename().then((newFilePath) => {
+ reflectRenameOpenedEntry(path, newFilePath);
+ return [path, newFilePath];
+ });
});
function removeTagsFromSideCar(
@@ -731,11 +767,12 @@ export const TaggingActionsContextProvider = ({
prefixTagContainer,
);
if (path !== newFilePath) {
- const success = await renameFile(path, newFilePath);
+ const success = await renameFile(path, newFilePath, reflect);
if (!success) {
reject(new Error('Error renaming file'));
return;
}
+ reflectRenameOpenedEntry(path, newFilePath, true);
}
resolve(newFilePath);
} else {
diff --git a/app/services/meta-loader.ts b/app/services/meta-loader.ts
index 29d047797..70f264c54 100644
--- a/app/services/meta-loader.ts
+++ b/app/services/meta-loader.ts
@@ -89,7 +89,7 @@ function setThumbForEntry(
entry: TS.FileSystemEntry,
meta: Array<any>,
): TS.FileSystemEntry {
- const thumbEntry = { ...entry };
+ const thumbEntry = { ...entry, tags: [] };
let thumbPath = getThumbFileLocationForFile(
entry.path,
PlatformIO.getDirSeparator(),
diff --git a/app/services/utils-io.ts b/app/services/utils-io.ts
index 7957b7ffa..3befeb3cd 100644
--- a/app/services/utils-io.ts
+++ b/app/services/utils-io.ts
@@ -61,11 +61,11 @@ export function getMetaForEntry(
entry: TS.FileSystemEntry,
metaFilePath?: string,
): Promise<TS.FileSystemEntry> {
- if (entry.meta) {
- // && Object.keys(entry.meta).length > 0) {
- // entry is Enhanced
- return Promise.resolve(entry);
- }
+ //if (entry.meta) {
+ // && Object.keys(entry.meta).length > 0) {
+ // entry is Enhanced
+ // return Promise.resolve(entry);
+ //}
if (!metaFilePath) {
if (entry.isFile) {
metaFilePath = getMetaFileLocationForFile(
diff --git a/tests/e2e/search.pw.e2e.js b/tests/e2e/search.pw.e2e.js
index 2c230f4cf..becdca9eb 100644
--- a/tests/e2e/search.pw.e2e.js
+++ b/tests/e2e/search.pw.e2e.js
@@ -235,7 +235,7 @@ test.describe('TST06 - Test Search in file structure:', () => {
await expectElementSelected(
'sample' + ' ' + tags1.join(' ') + '.' + file1,
- false,
+ true,
);
const file2 = 'jpg';
@@ -244,7 +244,7 @@ test.describe('TST06 - Test Search in file structure:', () => {
await expectElementSelected(
'sample' + ' ' + tags2.join(' ') + '.' + file2,
- false,
+ true,
);
const file3 = 'gif';
@@ -253,7 +253,7 @@ test.describe('TST06 - Test Search in file structure:', () => {
await expectElementSelected(
'sample' + ' ' + tags3.join(' ') + '.' + file3,
- false,
+ true,
);
function getFileName(fileExt, tags) {