Skip to content

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

change location on open directory (#2338)

Stanimird3598edcb798
diff --git a/src/renderer/components/DirectoryTreeView.tsx b/src/renderer/components/DirectoryTreeView.tsx
index f1ae6950c..3f9113e14 100644
--- a/src/renderer/components/DirectoryTreeView.tsx
+++ b/src/renderer/components/DirectoryTreeView.tsx
@@ -84,11 +84,11 @@ const DirectoryTreeView = forwardRef(
//const dispatch: AppDispatch = useDispatch();
// When currentLocationId changes refresh `data`
- useEffect(() => {
+ /*useEffect(() => {
if (data && currentLocationId === location.locationID) {
setData(undefined);
}
- }, [currentLocationId]);
+ }, [currentLocationId]);*/
// initially loadSubDirectories or whenever data was just cleared from previous useEffect
useEffect(() => {
diff --git a/src/renderer/hooks/DirectoryContentContextProvider.tsx b/src/renderer/hooks/DirectoryContentContextProvider.tsx
index 9d75f1262..43d2c4695 100644
--- a/src/renderer/hooks/DirectoryContentContextProvider.tsx
+++ b/src/renderer/hooks/DirectoryContentContextProvider.tsx
@@ -232,6 +232,7 @@ export const DirectoryContentContextProvider = ({
findLocation,
skipInitialDirList,
getLocationPath,
+ changeLocation,
} = useCurrentLocationContext();
const { actions } = useEditedEntryContext();
const { metaActions, setReflectMetaActions } = useEditedEntryMetaContext();
@@ -1009,6 +1010,13 @@ export const DirectoryContentContextProvider = ({
location: CommonLocation = undefined,
): Promise<boolean> {
if (dirPath !== undefined) {
+ if (
+ location &&
+ currentLocation &&
+ currentLocation.type !== location.type
+ ) {
+ changeLocation(location, true);
+ }
const cLocation = location || findLocation();
if (cLocation) {
return cLocation.checkDirExist(dirPath).then((exist) => {