Skip to content

Commit

Permalink
Merge pull request #40364 from GandalfGwaihir/issue39848
Browse files Browse the repository at this point in the history
[Fix]: Tapping outside quickly after clear status leads the user going back to the report screen
  • Loading branch information
youssef-lr authored May 29, 2024
2 parents 0cce499 + f55c624 commit 08b3f04
Showing 1 changed file with 22 additions and 2 deletions.
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<{
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

0 comments on commit 08b3f04

Please sign in to comment.