Skip to content

Commit

Permalink
fix(collection-flow): now using the right value for file on change in…
Browse files Browse the repository at this point in the history
… document field (#1754)
  • Loading branch information
Omri-Levy authored Dec 4, 2023
1 parent 114338d commit 6182728
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,9 @@ export const DocumentField = (

return fileId;
}, [payload, definition, inputIndex]);

//@ts-ignore
const { file } = useFileRepository(collectionFlowFileStorage, fileId);
useFileRepository(collectionFlowFileStorage, fileId);

useLayoutEffect(() => {
if (!fileId) return;
Expand Down Expand Up @@ -156,6 +157,7 @@ export const DocumentField = (
const pathToDocumentsList = destinationParser.extractRootPath();
const pathToPage = destinationParser.extractPagePath();
const pathToFileId = destinationParser.extractFileIdPath();
const file = collectionFlowFileStorage.getFileById(fileId);

const context = stateApi.getContext();
//@ts-ignore
Expand Down Expand Up @@ -205,7 +207,7 @@ export const DocumentField = (

sendEvent('onChange');
},
[stateApi, options, definition, inputIndex, file, sendEvent],
[stateApi, options, definition, inputIndex, sendEvent],
);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ export const FileUploaderField = forwardRef(

registerFile(file, uploadResult.fileId);

const registeredFile = fileStorage.getFileById(uploadResult.fileId);

if (!registeredFile) {
throw new Error(
`Failed to register file with the id of ${uploadResult.fileId} in the file repository`,
);
}

onChange(uploadResult.fileId);
},
[uploadFile, registerFile, fileStorage, onChange],
Expand Down

0 comments on commit 6182728

Please sign in to comment.