Fix race condition for keyboard tracker (#6902)

This commit is contained in:
Elias Nahum 2022-12-22 20:46:19 +02:00 committed by GitHub
parent da4470bd78
commit 49c242e300
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -24,10 +24,13 @@ export const useKeyboardTrackingPaused = (keyboardTrackingRef: RefObject<Keyboar
};
const commandListener = Navigation.events().registerCommandListener(() => {
if (!isPostDraftPaused.current) {
isPostDraftPaused.current = true;
keyboardTrackingRef.current?.pauseTracking(trackerId);
}
setTimeout(() => {
const visibleScreen = NavigationStore.getVisibleScreen();
if (!isPostDraftPaused.current && !screens.includes(visibleScreen)) {
isPostDraftPaused.current = true;
keyboardTrackingRef.current?.pauseTracking(trackerId);
}
});
});
const commandCompletedListener = Navigation.events().registerCommandCompletedListener(() => {