Skip to content

Commit 5fb3cb6

Browse files
authored
Merge pull request #43542 from dominictb/fix/43089
2 parents 4dc1710 + ae03a7f commit 5fb3cb6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/pages/home/report/UserTypingEventListener.tsx

+17
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,23 @@ function UserTypingEventListener({report, lastVisitedPath}: UserTypingEventListe
2424
const reportID = report.reportID;
2525
const isFocused = useIsFocused();
2626
const route = useRoute<RouteProp<CentralPaneNavigatorParamList, typeof SCREENS.REPORT>>();
27+
28+
useEffect(
29+
() => () => {
30+
if (!didSubscribeToReportTypingEvents.current) {
31+
return;
32+
}
33+
34+
// unsubscribe from report typing events when the component unmounts
35+
didSubscribeToReportTypingEvents.current = false;
36+
InteractionManager.runAfterInteractions(() => {
37+
Report.unsubscribeFromReportChannel(reportID);
38+
});
39+
},
40+
// eslint-disable-next-line react-hooks/exhaustive-deps
41+
[],
42+
);
43+
2744
useEffect(() => {
2845
// Ensures any optimistic report that is being created (ex: a thread report) gets created and initialized successfully before subscribing
2946
if (route?.params?.reportID !== reportID) {

0 commit comments

Comments
 (0)