From 17870f4d2d14b1d37f2b9eec85bab76102b88825 Mon Sep 17 00:00:00 2001 From: hel-axelor <101327380+hel-axelor@users.noreply.github.com> Date: Wed, 28 Feb 2024 13:52:04 +0100 Subject: [PATCH] feat: add props on Loader to force user to leave screen (#379) * RM#73991 --- .../apps/stock/src/screens/loader/LoaderScreen.js | 1 + .../components/templates/Loader/LoaderPopup.tsx | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/apps/stock/src/screens/loader/LoaderScreen.js b/packages/apps/stock/src/screens/loader/LoaderScreen.js index 567148e7cf..a73517f0fe 100644 --- a/packages/apps/stock/src/screens/loader/LoaderScreen.js +++ b/packages/apps/stock/src/screens/loader/LoaderScreen.js @@ -76,6 +76,7 @@ const LoaderScreen = () => { onSuccess={handleSuccessAction} onError={handleErrorAction} disabled={false} + autoLeave={true} /> diff --git a/packages/core/src/components/templates/Loader/LoaderPopup.tsx b/packages/core/src/components/templates/Loader/LoaderPopup.tsx index 41466aa5d7..a941c634f0 100644 --- a/packages/core/src/components/templates/Loader/LoaderPopup.tsx +++ b/packages/core/src/components/templates/Loader/LoaderPopup.tsx @@ -38,6 +38,7 @@ interface LoaderPopupProps { onError: () => void; start?: boolean; disabled?: boolean; + autoLeave?: boolean; timeout?: number; } @@ -47,6 +48,7 @@ const LoaderPopup = ({ onError, start = false, disabled = false, + autoLeave = false, timeout = 100, }: LoaderPopupProps) => { const navigation = useNavigation(); @@ -87,7 +89,8 @@ const LoaderPopup = ({ timeoutRef.current = setTimeout(() => { setActivityIndicator(false); - setShowPopup(true); + + autoLeave ? handleNotifyMe() : setShowPopup(true); }, timeout); } @@ -95,7 +98,15 @@ const LoaderPopup = ({ setActivityIndicator(false); clearTimeout(timeoutRef.current); }; - }, [timeout, loading, showPopup, setActivityIndicator, setShowPopup]); + }, [ + timeout, + loading, + showPopup, + autoLeave, + setActivityIndicator, + setShowPopup, + handleNotifyMe, + ]); if (!loading || !showPopup) { return null;