lockApp on deleteAll

Signed-off-by: Virginie Ky <virginie.ky@gmail.com>
This commit is contained in:
Virginie Ky 2020-03-27 12:13:19 +01:00
parent 1274645f0e
commit 3c5cb15c31
3 changed files with 30 additions and 14 deletions

View File

@ -6,7 +6,7 @@ const Overlay = styled.div`
right: 0;
bottom: 0;
left: 0;
z-index: 1040;
z-index: 1140;
&:before {
content: '';
position: fixed;

View File

@ -79,7 +79,9 @@ const EditForm = forwardRef(
useEffect(() => {
if (isImg || isVideo) {
if (prefixedFileURL) {
setSrc(prefixedFileURL);
// Adding performance.now forces the browser no to cache the img
// https://stackoverflow.com/questions/126772/how-to-force-a-web-browser-not-to-cache-images
setSrc(`${prefixedFileURL}?${performance.now()}`);
} else {
const reader = new FileReader();

View File

@ -212,11 +212,8 @@ const HomePage = () => {
const handleDeleteMediaFromModal = async id => {
handleClickToggleModal();
const overlayblockerParams = {
children: <div />,
noGradient: true,
};
strapi.lockApp(overlayblockerParams);
lockAppWithOverlay();
try {
await deleteMedia(id);
@ -235,14 +232,22 @@ const HomePage = () => {
};
const handleDeleteMedias = async () => {
await Promise.all(dataToDelete.map(item => deleteMedia(item.id)));
dispatch({
type: 'CLEAR_DATA_TO_DELETE',
});
setIsPopupOpen(false);
fetchListData();
lockAppWithOverlay();
await Promise.all(dataToDelete.map(item => deleteMedia(item.id)))
.then(() => {
dispatch({
type: 'CLEAR_DATA_TO_DELETE',
});
fetchListData();
strapi.unlockApp();
})
.catch(() => {
strapi.unlockApp();
});
};
const handleModalClose = () => {
@ -260,6 +265,15 @@ const HomePage = () => {
});
};
const lockAppWithOverlay = () => {
const overlayblockerParams = {
children: <div />,
noGradient: true,
};
strapi.lockApp(overlayblockerParams);
};
const resetModalState = () => {
setModalInitialStep('browse');
setFileToEdit(null);