@bindu-dashing/dam-solution-v2 5.9.257 → 5.9.260

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.
@@ -20,7 +20,7 @@ import CustomButton from "../../common/Button";
20
20
  import { showNotification } from "../../common/notifications";
21
21
  import { FILE_UPLOAD_ERROR, SOMETHING_WENT_WRONG, UPDATE_SUCCESS, } from "../../utilities/constants/messages";
22
22
  import { CREATE_FILE_URL, FILE_UPLOAD_URL, SAVE_EDITED_FILE_THUMBNAIL_URL, SAVE_EDITED_FILE_URL, } from "../../utilities/constants/apiUrls";
23
- import { generateFoldersQueryKey, invalidateData, QueryKeys, } from "../../utilities/constants/queryKeys";
23
+ import { QueryKeys } from "../../utilities/constants/queryKeys";
24
24
  import { useQueryClient } from "react-query";
25
25
  import { useDamConfig } from "../../hocs/DamConfigContext";
26
26
  import { createApiClient } from "../../hocs/configureAxios";
@@ -39,8 +39,12 @@ const ImageEditorComponent = ({ file, handleClose, }) => {
39
39
  const { rootFolderId, brand } = damConfig;
40
40
  const brandId = get(brand, "_id");
41
41
  const api = useMemo(() => createApiClient(damConfig), [damConfig]);
42
- const { type, folderId } = useAppParams();
43
- const currentFolderId = folderId || rootFolderId;
42
+ const { folderId } = useAppParams();
43
+ // file.folderId is the folder the file actually lives in. Prefer it because
44
+ // `useAppParams().folderId` is undefined when the picker is opened as a
45
+ // modal (no URL change) — that was causing uploads to land in the root
46
+ // folder and invalidations to miss the picker's active query.
47
+ const currentFolderId = get(file, "folderId") || folderId || rootFolderId;
44
48
  const [state, setState] = useState({
45
49
  loading: false,
46
50
  confirmOpen: false,
@@ -48,8 +52,13 @@ const ImageEditorComponent = ({ file, handleClose, }) => {
48
52
  const { loading, confirmOpen } = state;
49
53
  const editorRef = useRef(null);
50
54
  const invalidateAfterChange = () => {
51
- invalidateData(queryClient, generateFoldersQueryKey(type), currentFolderId);
52
- invalidateData(queryClient, QueryKeys.FILE, get(file, "_id"));
55
+ // Prefix-only invalidation so we hit every relevant query regardless of
56
+ // its second key segment (folderId, picker id, mode, etc.). Going by
57
+ // exact key was missing the picker's active query because its folderId
58
+ // doesn't match useAppParams().folderId when the picker is a modal.
59
+ queryClient.invalidateQueries({ queryKey: [QueryKeys.FOLDERS] });
60
+ queryClient.invalidateQueries({ queryKey: [QueryKeys.IMAGE_PICKERS] });
61
+ queryClient.invalidateQueries({ queryKey: [QueryKeys.FILE] });
53
62
  };
54
63
  const handleOverwrite = () => __awaiter(void 0, void 0, void 0, function* () {
55
64
  var _a;
@@ -131,8 +140,15 @@ const ImageEditorComponent = ({ file, handleClose, }) => {
131
140
  setState((prev) => (Object.assign(Object.assign({}, prev), { loading: false })));
132
141
  return;
133
142
  }
134
- // 3) register the file in the DB so it shows up in the folder grid
143
+ // 3) register the file in the DB so it shows up in the folder grid.
144
+ // Inherit assetId / metadata / teamIds from the original file so the new
145
+ // one belongs to the same asset template and keeps the same field values.
146
+ const inheritedMetadata = get(file, "metadata") || {};
147
+ const inheritedTeamIds = get(file, "teamIds") || [];
135
148
  yield api.post(CREATE_FILE_URL, {
149
+ assetId: get(file, "assetId"),
150
+ teamIds: inheritedTeamIds,
151
+ metadata: inheritedMetadata,
136
152
  folderId: currentFolderId,
137
153
  files: [
138
154
  {
@@ -140,8 +156,8 @@ const ImageEditorComponent = ({ file, handleClose, }) => {
140
156
  path: filePath,
141
157
  size: editedFile.size,
142
158
  mimetype,
143
- metadata: {},
144
- teamIds: get(file, "teamIds") || [],
159
+ metadata: inheritedMetadata,
160
+ teamIds: inheritedTeamIds,
145
161
  },
146
162
  ],
147
163
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bindu-dashing/dam-solution-v2",
3
- "version": "5.9.257",
3
+ "version": "5.9.260",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.0.1",
6
6
  "@emoji-mart/data": "^1.2.1",