Skip to content

Commit

Permalink
feat : add auto leave props for loader popup
Browse files Browse the repository at this point in the history
  • Loading branch information
hel-axelor committed Feb 2, 2024
1 parent a8cbc51 commit da78ed7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/apps/stock/src/screens/loader/LoaderScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const LoaderScreen = () => {
onSuccess={handleSuccessAction}
onError={handleErrorAction}
disabled={false}
autoLeave={true}
/>
</View>
</Screen>
Expand Down
15 changes: 12 additions & 3 deletions packages/core/src/components/templates/Loader/LoaderPopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ interface LoaderPopupProps {
runProccess: boolean;
timeout: number;
disabled: boolean;
autoLeave: boolean;
}

const LoaderPopup = ({
Expand All @@ -48,6 +49,7 @@ const LoaderPopup = ({
runProccess = false,
timeout = 100,
disabled = false,
autoLeave = false,
}: LoaderPopupProps) => {
const navigation = useNavigation();
const I18n = useTranslator();
Expand All @@ -66,10 +68,10 @@ const LoaderPopup = ({
});

useEffect(() => {
if (notifyMe) {
if (autoLeave || notifyMe) {
navigation.goBack();
}
}, [navigation, notifyMe]);
}, [navigation, autoLeave, notifyMe]);

useEffect(() => {
if (runProccess) {
Expand All @@ -94,7 +96,14 @@ const LoaderPopup = ({
setActivityIndicator(false);
clearTimeout(timeoutRef.current);
};
}, [timeout, loading, showPopup, setActivityIndicator, setShowPopup]);
}, [
timeout,
loading,
showPopup,
autoLeave,
setActivityIndicator,
setShowPopup,
]);

if (!loading || !showPopup) {
return null;
Expand Down

0 comments on commit da78ed7

Please sign in to comment.