Skip to content

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

fix rename entry from opened file

sytolk5437c41ee052
diff --git a/src/renderer/hooks/FsActionsContextProvider.tsx b/src/renderer/hooks/FsActionsContextProvider.tsx
index a8f94cdcd..19628b822 100644
--- a/src/renderer/hooks/FsActionsContextProvider.tsx
+++ b/src/renderer/hooks/FsActionsContextProvider.tsx
@@ -41,7 +41,7 @@ import { useNotificationContext } from '-/hooks/useNotificationContext';
import { useLocationIndexContext } from '-/hooks/useLocationIndexContext';
import { useSelectedEntriesContext } from '-/hooks/useSelectedEntriesContext';
import { usePlatformFacadeContext } from '-/hooks/usePlatformFacadeContext';
-import { useFSWatcherContext } from '-/hooks/useFSWatcherContext';
+import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';
type FsActionsContextData = {
renameDirectory: (
@@ -73,6 +73,7 @@ export const FsActionsContextProvider = ({
}: FsActionsContextProviderProps) => {
const { t } = useTranslation();
const { setSelectedEntries, selectedEntries } = useSelectedEntriesContext();
+ const { reflectRenameOpenedEntry } = useOpenedEntryContext();
const { openDirectory, currentDirectoryPath, reflectRenameEntries } =
useDirectoryContentContext();
const { reflectRenameEntry } = useLocationIndexContext();
@@ -101,10 +102,11 @@ export const FsActionsContextProvider = ({
});
} else {
reflectRenameEntries([[directoryPath, newDirPath]]).then(() => {
+ reflectRenameOpenedEntry(directoryPath, newDirPath);
reflectRenameEntry(directoryPath, newDirPath);
- dispatch(
+ /*dispatch(
AppActions.reflectRenameEntry(directoryPath, newDirPath),
- );
+ );*/
});
}
setSelectedEntries([]);
@@ -173,13 +175,14 @@ export const FsActionsContextProvider = ({
if (reflect) {
reflectRenameEntries([[filePath, newFilePathFromPromise]]).then(
() => {
+ reflectRenameOpenedEntry(filePath, newFilePathFromPromise);
reflectRenameEntry(filePath, newFilePathFromPromise);
- dispatch(
+ /*dispatch(
AppActions.reflectRenameEntry(
filePath,
newFilePathFromPromise,
),
- );
+ );*/
},
);
}
@@ -196,13 +199,14 @@ export const FsActionsContextProvider = ({
if (reflect) {
reflectRenameEntries([[filePath, newFilePathFromPromise]]).then(
() => {
+ reflectRenameOpenedEntry(filePath, newFilePathFromPromise);
reflectRenameEntry(filePath, newFilePathFromPromise);
- dispatch(
+ /*dispatch(
AppActions.reflectRenameEntry(
filePath,
newFilePathFromPromise,
),
- );
+ );*/
},
);
}
diff --git a/src/renderer/hooks/OpenedEntryContextProvider.tsx b/src/renderer/hooks/OpenedEntryContextProvider.tsx
index 68140b8f3..3099a271f 100644
--- a/src/renderer/hooks/OpenedEntryContextProvider.tsx
+++ b/src/renderer/hooks/OpenedEntryContextProvider.tsx
@@ -1033,23 +1033,23 @@ export const OpenedEntryContextProvider = ({
}
function reflectRenameOpenedEntry(entryPath, newEntryPath, reload = false) {
- if (openedEntries && openedEntries.length > 0) {
- if (openedEntries.some((entry) => entry.path === entryPath)) {
- if (currentLocation) {
- updateHistory(
- { ...currentLocation, path: currentLocationPath },
- currentDirectoryPath,
- newEntryPath,
- );
- }
- if (reload) {
- openEntry(newEntryPath);
- } else {
- const newEntry = getRenamedEntry(entryPath, newEntryPath);
- setSharedLinks(newEntry);
- setOpenedEntries([newEntry]);
- //addToEntryContainer({ ...openedEntries[0], path: newEntryPath });
- }
+ //if (openedEntries && openedEntries.length > 0) {
+ if (currentEntry.current.path === entryPath) {
+ //if (openedEntries.some((entry) => entry.path === entryPath)) {
+ if (currentLocation) {
+ updateHistory(
+ { ...currentLocation, path: currentLocationPath },
+ currentDirectoryPath,
+ newEntryPath,
+ );
+ }
+ if (reload) {
+ openEntry(newEntryPath);
+ } else {
+ const newEntry = getRenamedEntry(entryPath, newEntryPath);
+ setSharedLinks(newEntry);
+ setOpenedEntries([newEntry]);
+ //addToEntryContainer({ ...openedEntries[0], path: newEntryPath });
}
}
}