Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix]: Tapping outside quickly after clear status leads the user going back to the report screen #40364

Merged
merged 11 commits into from
May 29, 2024
24 changes: 22 additions & 2 deletions src/pages/settings/Profile/CustomStatus/StatusPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,26 @@ function StatusPage({draftStatus, currentUserPersonalDetails}: StatusPageProps)
return DateUtils.isTimeAtLeastOneMinuteInFuture({dateTimeString: clearAfterTime});
}, [draftClearAfter, currentUserClearAfter]);

const navigateBackToPreviousScreenTask = useRef<{
allgandalf marked this conversation as resolved.
Show resolved Hide resolved
then: (
onfulfilled?: () => typeof InteractionManager.runAfterInteractions,
onrejected?: () => typeof InteractionManager.runAfterInteractions,
) => Promise<typeof InteractionManager.runAfterInteractions>;
done: (...args: Array<typeof InteractionManager.runAfterInteractions>) => typeof InteractionManager.runAfterInteractions;
cancel: () => void;
} | null>(null);

useEffect(
() => () => {
if (!navigateBackToPreviousScreenTask.current) {
return;
}

navigateBackToPreviousScreenTask.current.cancel();
},
[],
);

const navigateBackToPreviousScreen = useCallback(() => Navigation.goBack(), []);
const updateStatus = useCallback(
({emojiCode, statusText}: FormOnyxValues<typeof ONYXKEYS.FORMS.SETTINGS_STATUS_SET_FORM>) => {
Expand All @@ -90,7 +110,7 @@ function StatusPage({draftStatus, currentUserPersonalDetails}: StatusPageProps)
clearAfter: clearAfterTime !== CONST.CUSTOM_STATUS_TYPES.NEVER ? clearAfterTime : '',
});
User.clearDraftCustomStatus();
InteractionManager.runAfterInteractions(() => {
navigateBackToPreviousScreenTask.current = InteractionManager.runAfterInteractions(() => {
navigateBackToPreviousScreen();
});
},
Expand All @@ -106,7 +126,7 @@ function StatusPage({draftStatus, currentUserPersonalDetails}: StatusPageProps)
});
formRef.current?.resetForm({[INPUT_IDS.EMOJI_CODE]: ''});

InteractionManager.runAfterInteractions(() => {
navigateBackToPreviousScreenTask.current = InteractionManager.runAfterInteractions(() => {
navigateBackToPreviousScreen();
});
};
Expand Down
Loading