@bindu-dashing/dam-solution-v2 5.8.14 → 5.8.16
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.
|
@@ -105,14 +105,49 @@ function FolderTree({ currentRootId, expandedKeys, selectedKeys, handleExpand, s
|
|
|
105
105
|
});
|
|
106
106
|
const response = yield api.get(`${FETCH_FOLDER_URL.replace(":folderId", fid)}?isPagination=false&includeFiles=false&includeSubFoldersCount=true&fetchMainFolders=true&globalSearch=${fid == rootFolderId ? globalSearch : ""}`);
|
|
107
107
|
const newFolders = get(response, "data.folders", []);
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
console.log('## newFolders', newFolders, 'fid:', fid, 'rootFolderId:', rootFolderId, 'isRoot:', fid === rootFolderId);
|
|
109
|
+
// Always use fresh results - sort them
|
|
110
|
+
const sorted = sortFoldersRecursively(newFolders, "name", sortOrder);
|
|
111
|
+
console.log('## sorted folders (length):', sorted.length, 'folders before update:', folders === null || folders === void 0 ? void 0 : folders.length);
|
|
112
|
+
// If results are empty and we don't have a rootFolderId, or if fid matches rootFolderId,
|
|
113
|
+
// always replace all folders with fresh results (even if empty)
|
|
114
|
+
if (fid === rootFolderId || (!rootFolderId && sorted.length === 0)) {
|
|
115
|
+
// For root folder, always replace with fresh results (even if empty)
|
|
116
|
+
// This ensures when API returns empty, we clear all folders
|
|
117
|
+
console.log('## Setting root folders to (length):', sorted.length);
|
|
118
|
+
setFolders(sorted);
|
|
110
119
|
}
|
|
111
120
|
else {
|
|
121
|
+
// For subfolders, always replace children with fresh data (even if empty array)
|
|
122
|
+
// This ensures we don't keep stale/previous data when API returns empty results
|
|
112
123
|
setFolders((prev) => {
|
|
124
|
+
console.log('## Updating subfolders, prev length:', prev === null || prev === void 0 ? void 0 : prev.length, 'fid:', fid, 'sorted length:', sorted.length);
|
|
125
|
+
// If we're trying to update a subfolder but get empty results,
|
|
126
|
+
// we should still update that folder's children to be empty
|
|
127
|
+
if (!prev || prev.length === 0) {
|
|
128
|
+
// If no previous state, return empty (since we're updating a subfolder, not root)
|
|
129
|
+
return sorted.length > 0 ? sorted : [];
|
|
130
|
+
}
|
|
131
|
+
// Clone previous state to ensure immutability
|
|
113
132
|
const cloned = cloneDeep(prev);
|
|
114
|
-
|
|
115
|
-
|
|
133
|
+
// insertSubfolders will replace children with fresh sorted data (even if empty array)
|
|
134
|
+
// This ensures previous children are cleared when API returns empty results
|
|
135
|
+
const result = insertSubfolders(cloned, fid, sorted);
|
|
136
|
+
console.log('## After insertSubfolders, result length:', result === null || result === void 0 ? void 0 : result.length);
|
|
137
|
+
// Verify the folder was found and updated
|
|
138
|
+
const folderFound = result.some((node) => {
|
|
139
|
+
const checkNode = (n) => {
|
|
140
|
+
if (n._id === fid)
|
|
141
|
+
return true;
|
|
142
|
+
if (isArray(n.children)) {
|
|
143
|
+
return n.children.some(checkNode);
|
|
144
|
+
}
|
|
145
|
+
return false;
|
|
146
|
+
};
|
|
147
|
+
return checkNode(node);
|
|
148
|
+
});
|
|
149
|
+
console.log('## Folder found in tree:', folderFound);
|
|
150
|
+
return result;
|
|
116
151
|
});
|
|
117
152
|
}
|
|
118
153
|
setState((prevState) => {
|
|
@@ -159,6 +194,7 @@ function FolderTree({ currentRootId, expandedKeys, selectedKeys, handleExpand, s
|
|
|
159
194
|
const toggleEditModal = (folder = {}) => setState((prev) => (Object.assign(Object.assign({}, prev), { selectedFolder: folder, showEditModal: !prev.showEditModal })));
|
|
160
195
|
const toggleDeleteModal = (folder = {}) => setState((prev) => (Object.assign(Object.assign({}, prev), { selectedFolder: folder, showConfirmationModal: !prev.showConfirmationModal })));
|
|
161
196
|
const getFoldersTree = (folders = []) => {
|
|
197
|
+
console.log('## folders', folders);
|
|
162
198
|
const transform = (tree = []) => map(tree, (folder) => {
|
|
163
199
|
const key = get(folder, "_id", "");
|
|
164
200
|
const name = get(folder, "name", "");
|
|
@@ -319,6 +355,7 @@ function FolderTree({ currentRootId, expandedKeys, selectedKeys, handleExpand, s
|
|
|
319
355
|
return Object.assign(Object.assign({}, prevState), { tempFolders: cloneDeep(customSorted), sortMode: "custom", enableDrag: false });
|
|
320
356
|
});
|
|
321
357
|
};
|
|
358
|
+
console.log('## folders in FolderTree', tempFolders, folders);
|
|
322
359
|
return (_jsxs(_Fragment, { children: [!screens.md && collapse && (_jsxs("div", { className: `md-lib-bg-textColorActive dark:md-lib-bg-darkSecondaryColor md-lib-p-1 md-lib-rounded md-lib-absolute md-lib-top-16 md-lib-left-1`, children: [" ", _jsx(FaAngleRightbtn, { size: 24, className: "md-lib-text-textColor dark:md-lib-text-darkTextColor", onClick: toggleMenu })] })), _jsxs("div", { className: `md-lib-border-r md-lib-inline-table md-lib-border-borderColor dark:md-lib-border-darkBorderColor md-lib-bg-white dark:md-lib-bg-darkPrimaryHoverColor md-lib-px-2 md-lib-pt-1 md-lib-max-h-[calc(100%-76px)] md-lib-overflow-x-auto ${!screens.md &&
|
|
323
360
|
"md-lib-absolute md-lib-left-0 md-lib-z-30 md-lib-h-full"} ${!screens.md && collapse && "!-md-lib-left-full"}`, children: [!screens.md && !collapse && (_jsxs("div", { className: `md-lib-bg-textColorActive dark:md-lib-bg-darkSecondaryColor md-lib-p-1 md-lib-rounded md-lib-absolute md-lib-top-1 md-lib-right-1 md-lib-z-50`, children: [" ", _jsx(FaAngleLeftbtn, { size: 24, className: "md-lib-text-textColor dark:md-lib-text-darkTextColor", onClick: toggleMenu })] })), _jsx("div", { className: "md-lib-mb-2", children: _jsx(Input, { placeholder: "Search files (min. 2 characters required)", onChange: (e) => setState((prevState) => {
|
|
324
361
|
return Object.assign(Object.assign({}, prevState), { globalSearchValue: e.target.value });
|
|
@@ -19,16 +19,6 @@ export default function MyDriveMainContainer({ folders, setFolders }) {
|
|
|
19
19
|
if (params === null || params === void 0 ? void 0 : params.folderId) {
|
|
20
20
|
setSelectedKeys(params.folderId);
|
|
21
21
|
}
|
|
22
|
-
else if (params === null || params === void 0 ? void 0 : params.id) {
|
|
23
|
-
setSelectedKeys(params.id);
|
|
24
|
-
}
|
|
25
|
-
else if (params === null || params === void 0 ? void 0 : params.parentId) {
|
|
26
|
-
setSelectedKeys(params.parentId);
|
|
27
|
-
}
|
|
28
|
-
else if (rootFolderId) {
|
|
29
|
-
// Fallback to rootFolderId from config
|
|
30
|
-
setSelectedKeys(rootFolderId);
|
|
31
|
-
}
|
|
32
22
|
}, [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]);
|
|
33
23
|
const currentRootId = isArray(selectedKeys)
|
|
34
24
|
? selectedKeys.length
|