Skip to content

Commit 1c51127

Browse files
authored
Merge pull request #151 from sendbird/fix/typing-bubble-android
fix(CLNP-1459): not scrolled to bottom on android when typing bubble is rendered
2 parents 8c67c31 + a866422 commit 1c51127

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

packages/uikit-react-native/src/components/GroupChannelMessageRenderer/index.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useContext, useRef } from 'react';
1+
import React, { useContext, useEffect, useRef } from 'react';
22

33
import type { GroupChannelMessageProps, RegexTextPattern } from '@sendbird/uikit-react-native-foundation';
44
import {
@@ -302,12 +302,21 @@ const GroupChannelMessageRenderer: GroupChannelProps['Fragment']['renderMessage'
302302

303303
export const GroupChannelTypingIndicatorBubble = () => {
304304
const { sbOptions } = useSendbirdChat();
305+
const { publish } = useContext(GroupChannelContexts.PubSub);
305306
const { typingUsers } = useContext(GroupChannelContexts.TypingIndicator);
306307

307-
if (typingUsers.length === 0) return null;
308-
if (!sbOptions.uikit.groupChannel.channel.enableTypingIndicator) return null;
309-
if (!sbOptions.uikit.groupChannel.channel.typingIndicatorTypes.has(TypingIndicatorType.Bubble)) return null;
308+
const shouldRenderBubble = useIIFE(() => {
309+
if (typingUsers.length === 0) return false;
310+
if (!sbOptions.uikit.groupChannel.channel.enableTypingIndicator) return false;
311+
if (!sbOptions.uikit.groupChannel.channel.typingIndicatorTypes.has(TypingIndicatorType.Bubble)) return false;
312+
return true;
313+
});
314+
315+
useEffect(() => {
316+
if (shouldRenderBubble) publish({ type: 'TYPING_BUBBLE_RENDERED' });
317+
}, [shouldRenderBubble]);
310318

319+
if (!shouldRenderBubble) return null;
311320
return (
312321
<Box paddingHorizontal={16} marginTop={4} marginBottom={16}>
313322
<TypingIndicatorBubble typingUsers={typingUsers} />

packages/uikit-react-native/src/domain/groupChannel/component/GroupChannelMessageList.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ const GroupChannelMessageList = (props: GroupChannelProps['MessageList']) => {
7373
useEffect(() => {
7474
return subscribe(({ type }) => {
7575
switch (type) {
76+
case 'TYPING_BUBBLE_RENDERED':
7677
case 'MESSAGES_RECEIVED': {
7778
if (!props.scrolledAwayFromBottom) {
7879
scrollToBottom(true);

packages/uikit-react-native/src/domain/groupChannel/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,8 @@ export type GroupChannelPubSubContextPayload =
183183
data: {
184184
messages: SendbirdMessage[];
185185
};
186+
}
187+
| {
188+
type: 'TYPING_BUBBLE_RENDERED';
189+
data?: undefined;
186190
};

0 commit comments

Comments
 (0)