Skip to content

Commit

Permalink
fix(strapi-cms): Fix properly using the showDelay parameter from Strapi
Browse files Browse the repository at this point in the history
  • Loading branch information
relyks committed Aug 28, 2023
1 parent b3e7de4 commit b5397c5
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions static/js/Misc.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2092,7 +2092,6 @@ const InterruptingMessage = ({
const [interruptingMessageShowDelayHasElapsed, setInterruptingMessageShowDelayHasElapsed] = useState(false);
const [hasInteractedWithModal, setHasInteractedWithModal] = useState(false);
const strapi = useContext(StrapiDataContext);
const showDelay = strapi.modal.showDelay * 1000;

const markModalAsHasBeenInteractedWith = (modalName) => {
localStorage.setItem("modal_" + modalName, "true");
Expand Down Expand Up @@ -2178,7 +2177,7 @@ const InterruptingMessage = ({
if (shouldShow()) {
const timeoutId = setTimeout(() => {
setInterruptingMessageShowDelayHasElapsed(true);
}, showDelay);
}, strapi.modal.showDelay * 1000);
return () => clearTimeout(timeoutId); // clearTimeout on component unmount
}
}, [strapi.modal]); // execute useEffect when the modal changes
Expand Down Expand Up @@ -2263,7 +2262,6 @@ const Banner = ({ onClose }) => {
const [bannerShowDelayHasElapsed, setBannerShowDelayHasElapsed] = useState(false);
const [hasInteractedWithBanner, setHasInteractedWithBanner] = useState(false);
const strapi = useContext(StrapiDataContext);
const showDelay = strapi.banner.showDelay * 1000;

const markBannerAsHasBeenInteractedWith = (bannerName) => {
localStorage.setItem("banner_" + bannerName, "true");
Expand Down Expand Up @@ -2342,7 +2340,7 @@ const Banner = ({ onClose }) => {
document.body.classList.add("hasBannerMessage");
}
setBannerShowDelayHasElapsed(true);
}, showDelay);
}, strapi.banner.showDelay * 1000);
return () => clearTimeout(timeoutId); // clearTimeout on component unmount
}
}, [strapi.banner]); // execute useEffect when the modal changes
Expand Down

0 comments on commit b5397c5

Please sign in to comment.