Skip to content

Commit 84045be

Browse files
committed
refactor: move handleAppBackground logics up in the component
1 parent fbf8ecb commit 84045be

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

package/src/components/Channel/Channel.tsx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,22 @@ const ChannelWithContext = <
610610
}
611611
}, [threadPropsExists]);
612612

613+
const handleAppBackground = useCallback(() => {
614+
if (channel) {
615+
channel.sendEvent({ parent_id: thread?.id, type: 'typing.stop' } as StreamEvent<
616+
At,
617+
Ch,
618+
Co,
619+
Ev,
620+
Me,
621+
Re,
622+
Us
623+
>);
624+
}
625+
}, [thread?.id, channelId]);
626+
627+
useAppStateListener(undefined, handleAppBackground);
628+
613629
/**
614630
* CHANNEL CONSTANTS
615631
*/
@@ -674,22 +690,6 @@ const ChannelWithContext = <
674690
}
675691
};
676692

677-
const handleAppBackground = useCallback(() => {
678-
if (channel) {
679-
channel.sendEvent({ parent_id: thread?.id, type: 'typing.stop' } as StreamEvent<
680-
At,
681-
Ch,
682-
Co,
683-
Ev,
684-
Me,
685-
Re,
686-
Us
687-
>);
688-
}
689-
}, [thread?.id, channelId]);
690-
691-
useAppStateListener(undefined, handleAppBackground);
692-
693693
const handleEvent: EventHandler<At, Ch, Co, Ev, Me, Re, Us> = (event) => {
694694
if (thread) {
695695
const updatedThreadMessages =

0 commit comments

Comments
 (0)