Merge pull request #5683 from strapi/fix/toggle-refetch

Fix refetch files on toggle
This commit is contained in:
ELABBASSI Hicham 2020-04-02 10:17:23 +02:00 committed by GitHub
commit 96b2bc7921
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,6 +24,7 @@ const ModalStepper = ({
const [shouldDeleteFile, setShouldDeleteFile] = useState(false);
const [isFormDisabled, setIsFormDisabled] = useState(false);
const [formErrors, setFormErrors] = useState(null);
const [shouldRefetch, setShouldRefetch] = useState(false);
const [displayNextButton, setDisplayNextButton] = useState(false);
const [reducerState, dispatch] = useReducer(reducer, initialState, init);
const { currentStep, fileToEdit, filesToDownload, filesToUpload } = reducerState.toJS();
@ -213,6 +214,7 @@ const ModalStepper = ({
setIsFormDisabled(false);
setDisplayNextButton(false);
setFormErrors(null);
setShouldRefetch(false);
dispatch({
type: 'RESET_PROPS',
@ -333,7 +335,7 @@ const ModalStepper = ({
}
}
onToggle(true);
onToggle(shouldRefetch);
};
const handleUploadFiles = async () => {
@ -361,6 +363,8 @@ const ModalStepper = ({
false
);
setShouldRefetch(true);
dispatch({
type: 'REMOVE_FILE_TO_UPLOAD',
fileIndex: originalIndex,