@bindu-dashing/dam-solution-v2 5.8.20 → 5.8.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
11
|
import { Button, Dropdown, Grid, Input, Select, Tooltip, Tree } from "antd";
|
|
12
|
-
import { useEffect, useMemo, useState } from "react";
|
|
12
|
+
import { useEffect, useMemo, useState, useRef } from "react";
|
|
13
13
|
import { get, map, isArray, isObject, cloneDeep, first, sortBy, } from "lodash";
|
|
14
14
|
import { FaAngleLeft, FaAngleRight } from "react-icons/fa";
|
|
15
15
|
import { deleteFolders, } from "../react-query/services/folder-services";
|
|
@@ -130,8 +130,17 @@ function FolderTree({ currentRootId, expandedKeys, selectedKeys, handleExpand, s
|
|
|
130
130
|
}
|
|
131
131
|
});
|
|
132
132
|
// ✅ Load on mount & when currentRootId changes
|
|
133
|
+
// Use ref to track previous currentRootId to prevent unnecessary fetches
|
|
134
|
+
const prevCurrentRootIdRef = useRef(null);
|
|
133
135
|
useEffect(() => {
|
|
134
|
-
if (currentRootId) {
|
|
136
|
+
if (currentRootId && currentRootId !== prevCurrentRootIdRef.current) {
|
|
137
|
+
console.log('## FolderTree useEffect - currentRootId changed from', prevCurrentRootIdRef.current, 'to', currentRootId, 'rootFolderId:', rootFolderId);
|
|
138
|
+
prevCurrentRootIdRef.current = currentRootId;
|
|
139
|
+
fetchFolders(currentRootId);
|
|
140
|
+
}
|
|
141
|
+
else if (globalSearch !== globalSearchValue && currentRootId === rootFolderId) {
|
|
142
|
+
// Only refetch on global search change if we're on root folder
|
|
143
|
+
console.log('## FolderTree useEffect - globalSearch changed, refetching root folder');
|
|
135
144
|
fetchFolders(currentRootId);
|
|
136
145
|
}
|
|
137
146
|
}, [currentRootId, globalSearch]);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import FolderTree from "./FolderTree";
|
|
3
|
-
import { useEffect, useState } from "react";
|
|
3
|
+
import { useEffect, useState, useRef } from "react";
|
|
4
4
|
import { useDamConfig } from "../hocs/DamConfigContext";
|
|
5
5
|
import { isArray, map } from "lodash";
|
|
6
6
|
import DriveContainer from "./DriveContainer";
|
|
@@ -14,19 +14,31 @@ export default function MyDriveMainContainer({ folders, setFolders }) {
|
|
|
14
14
|
const [selectedKeys, setSelectedKeys] = useState([]);
|
|
15
15
|
const [expandedKeys, setExpandedKeys] = useState([]);
|
|
16
16
|
const [globalSearch, setGlobalSearch] = useState("");
|
|
17
|
+
// Track if we've initialized from params to prevent rootFolderId from overriding
|
|
18
|
+
const initializedFromParamsRef = useRef(false);
|
|
17
19
|
useEffect(() => {
|
|
18
20
|
// Priority: URL params > Props from ParamsProvider > rootFolderId from config
|
|
19
21
|
if (params === null || params === void 0 ? void 0 : params.folderId) {
|
|
22
|
+
console.log('## Setting selectedKeys from params.folderId:', params.folderId);
|
|
20
23
|
setSelectedKeys(params.folderId);
|
|
24
|
+
initializedFromParamsRef.current = true;
|
|
21
25
|
}
|
|
22
|
-
|
|
26
|
+
else if (!(params === null || params === void 0 ? void 0 : params.folderId) && rootFolderId && !selectedKeys && !initializedFromParamsRef.current) {
|
|
27
|
+
// Only set to rootFolderId if no params AND selectedKeys is empty AND we haven't initialized from params
|
|
28
|
+
console.log('## No params.folderId and no selectedKeys, using rootFolderId:', rootFolderId);
|
|
29
|
+
setSelectedKeys(rootFolderId);
|
|
30
|
+
}
|
|
31
|
+
}, [params === null || params === void 0 ? void 0 : params.folderId, params === null || params === void 0 ? void 0 : params.id, params === null || params === void 0 ? void 0 : params.parentId]);
|
|
32
|
+
// Priority: selectedKeys > params > rootFolderId
|
|
33
|
+
// Never fall back to rootFolderId if params.folderId is set
|
|
23
34
|
const currentRootId = isArray(selectedKeys)
|
|
24
35
|
? selectedKeys.length
|
|
25
36
|
? selectedKeys[selectedKeys.length - 1]
|
|
26
|
-
: rootFolderId
|
|
37
|
+
: ((params === null || params === void 0 ? void 0 : params.folderId) || (params === null || params === void 0 ? void 0 : params.id) || (params === null || params === void 0 ? void 0 : params.parentId) || rootFolderId)
|
|
27
38
|
: selectedKeys
|
|
28
39
|
? selectedKeys
|
|
29
|
-
: rootFolderId;
|
|
40
|
+
: ((params === null || params === void 0 ? void 0 : params.folderId) || (params === null || params === void 0 ? void 0 : params.id) || (params === null || params === void 0 ? void 0 : params.parentId) || rootFolderId);
|
|
41
|
+
console.log('## MyDriveMainContainer - selectedKeys:', selectedKeys, 'currentRootId:', currentRootId, 'rootFolderId:', rootFolderId);
|
|
30
42
|
const handleExpand = (keys) => {
|
|
31
43
|
setExpandedKeys(map(keys, (k) => k.toString()));
|
|
32
44
|
};
|