@bindu-dashing/dam-solution-v2 5.8.101 → 5.8.102
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.
|
@@ -12,7 +12,7 @@ import CustomLoader from "../common/loader/CustomLoader";
|
|
|
12
12
|
import { DownloadOutlined, } from "@ant-design/icons";
|
|
13
13
|
import AddFolder from "./AddFolder";
|
|
14
14
|
import { useMutation, useQueryClient } from "react-query";
|
|
15
|
-
import { archiveFiles, deleteFiles, downloadFiles, duplicateFiles, restoreFiles, unarchiveFiles, } from "../react-query/services/file-services";
|
|
15
|
+
import { archiveFiles, deleteFiles, downloadFiles, duplicateFiles, restoreFiles, unarchiveFiles, useFile, } from "../react-query/services/file-services";
|
|
16
16
|
import { ADDED_TO_FAV_MSG, ARCHIVE_OK_TEXT, ARCHIVE_SUCCESS, CREATE_SUCCESS, DELETE_CONFIRMATION_MESSAGE, DELETE_MESSAGE_DESCRIPTION, DELETE_OK_TEXT, DELETE_SUCCESS, INVALID_URL, REMOVED_FROM_FAV_MSG, RESTORE_SUCCESS, SOMETHING_WENT_WRONG, } from "../utilities/constants/messages";
|
|
17
17
|
import { getSelectedFiles, } from "../react-query/hooks/folder-hooks";
|
|
18
18
|
import { generateFoldersQueryKey, invalidateData, QueryKeys, } from "../utilities/constants/queryKeys";
|
|
@@ -44,6 +44,20 @@ function FileMenuOptions({ file, folderIds = [], fileIds = [], folder, onCloseSe
|
|
|
44
44
|
const { folderId, type } = useAppParams();
|
|
45
45
|
const api = useMemo(() => createApiClient(damConfig), [damConfig]);
|
|
46
46
|
const queryClient = useQueryClient();
|
|
47
|
+
// Fetch file data from API if file is null but we have a single fileId (no folders)
|
|
48
|
+
const singleFileId = useMemo(() => {
|
|
49
|
+
if (file)
|
|
50
|
+
return ""; // Already have file data, no need to fetch
|
|
51
|
+
if (get(fileIds, "length") === 1 && get(folderIds, "length") === 0) {
|
|
52
|
+
return first(fileIds) || "";
|
|
53
|
+
}
|
|
54
|
+
return "";
|
|
55
|
+
}, [file, fileIds, folderIds]);
|
|
56
|
+
const { data: fetchedFileData } = useFile(api, singleFileId);
|
|
57
|
+
// Use fetched file data if file prop is null
|
|
58
|
+
const effectiveFile = useMemo(() => {
|
|
59
|
+
return file || fetchedFileData || null;
|
|
60
|
+
}, [file, fetchedFileData]);
|
|
47
61
|
const isBulkAction = useMemo(() => !!get(folderIds, "length", 0) || !!get(fileIds, "length", 0), [folderIds, fileIds]);
|
|
48
62
|
const isMultiSelection = useMemo(() => get(folderIds, "length", 0) + get(fileIds, "length", 0) > DEFAULT_PAGE, [folderIds, fileIds]);
|
|
49
63
|
const [state, setState] = useState({
|
|
@@ -194,11 +208,13 @@ function FileMenuOptions({ file, folderIds = [], fileIds = [], folder, onCloseSe
|
|
|
194
208
|
},
|
|
195
209
|
});
|
|
196
210
|
const onDownloadFile = () => {
|
|
197
|
-
//
|
|
211
|
+
// Use effectiveFile which includes fetched data from API
|
|
212
|
+
const fileToUse = effectiveFile;
|
|
198
213
|
// Build fileIds list - use file._id if file exists, otherwise use fileIds prop
|
|
199
|
-
const fileIdsList =
|
|
200
|
-
const downloadUrl = get(
|
|
214
|
+
const fileIdsList = fileToUse && get(fileToUse, "_id") ? [get(fileToUse, "_id")] : fileIds;
|
|
215
|
+
const downloadUrl = get(fileToUse, "downloadUrl") || get(fileToUse, "s3Url") || get(fileToUse, "thumbnailUrl");
|
|
201
216
|
const isSingleFile = get(fileIdsList, "length", 0) === 1 && get(folderIds, "length", 0) === 0;
|
|
217
|
+
console.log("## onDownloadFile - effectiveFile:", fileToUse, "downloadUrl:", downloadUrl, "isSingleFile:", isSingleFile);
|
|
202
218
|
// If single file with downloadUrl available, open directly in new tab
|
|
203
219
|
if (isSingleFile && downloadUrl) {
|
|
204
220
|
window.open(downloadUrl, "_blank");
|
|
@@ -59,7 +59,6 @@ const FileDetails = ({ open, handleClose, file, files, fileIds, onCloseSelection
|
|
|
59
59
|
prevFileId.current = currentFileId;
|
|
60
60
|
}, [currentFileId]);
|
|
61
61
|
const currentFile = useMemo(() => {
|
|
62
|
-
console.log("## currentFile calc - file:", file, "initialFile:", initialFile, "fileData:", fileData, "isFetching:", isFetching, "id:", id, "currentIndex:", currentIndex);
|
|
63
62
|
// Priority: fileData (from API) > file prop > files array item > initialFile
|
|
64
63
|
if (fileData) {
|
|
65
64
|
return fileData;
|