Skip to content

Commit abe92cc

Browse files
committed
Implement parent message reaction info.
1 parent d0b6cf7 commit abe92cc

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

packages/uikit-react-native/src/components/ReactionAddons/MessageReactionAddon.tsx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import ReactionRoundedButton from './ReactionRoundedButton';
1212

1313
const NUM_COL = 4;
1414
const REACTION_MORE_KEY = 'reaction-more-button';
15+
type ReactionAddonType = 'default' | 'thread_parent_message';
1516

1617
const getUserReacted = (reaction: SendbirdReaction, userId = UNKNOWN_USER_ID) => {
1718
return reaction.userIds.indexOf(userId) > -1;
@@ -74,13 +75,13 @@ const createReactionButtons = (
7475
return buttons;
7576
};
7677

77-
const MessageReactionAddon = ({ channel, message }: { channel: SendbirdBaseChannel; message: SendbirdBaseMessage }) => {
78+
const MessageReactionAddon = ({ channel, message, reactionAddonType = 'default'}: { channel: SendbirdBaseChannel; message: SendbirdBaseMessage, reactionAddonType?: ReactionAddonType }) => {
7879
const { colors } = useUIKitTheme();
7980
const { emojiManager, currentUser } = useSendbirdChat();
8081
const { openReactionList, openReactionUserList } = useReaction();
81-
82-
if (!message.reactions?.length) return null;
83-
82+
83+
if (reactionAddonType === 'default' && !message.reactions?.length) return null;
84+
8485
const reactionButtons = createReactionButtons(
8586
channel,
8687
message,
@@ -90,11 +91,13 @@ const MessageReactionAddon = ({ channel, message }: { channel: SendbirdBaseChann
9091
(focusIndex) => openReactionUserList({ channel, message, focusIndex }),
9192
currentUser?.userId,
9293
);
93-
94+
95+
const containerStyle = reactionAddonType === 'default' ? styles.reactionContainer : styles.reactionThreadParentMessageContainer;
96+
9497
return (
9598
<Pressable
9699
style={[
97-
styles.reactionContainer,
100+
containerStyle,
98101
{ backgroundColor: colors.background, borderColor: colors.ui.reaction.rounded.enabled.background },
99102
]}
100103
>
@@ -112,6 +115,13 @@ const styles = createStyleSheet({
112115
borderRadius: 16,
113116
borderWidth: 1,
114117
},
118+
reactionThreadParentMessageContainer: {
119+
alignItems: 'stretch',
120+
flexDirection: 'row',
121+
flexWrap: 'wrap',
122+
padding: 8,
123+
borderRadius: 16,
124+
},
115125
marginRight: {
116126
marginRight: 4.5,
117127
},
@@ -121,3 +131,4 @@ const styles = createStyleSheet({
121131
});
122132

123133
export default MessageReactionAddon;
134+
export { ReactionAddonType };

packages/uikit-react-native/src/domain/groupChannelThread/component/GroupChannelThreadParentMessageInfo.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ const GroupChannelThreadParentMessageInfo = (props: GroupChannelThreadProps['Par
233233
<ThreadParentMessageRenderer {...messageProps}></ThreadParentMessageRenderer>
234234
</View>
235235
<View style={styles.reactionButtonContainer}>
236+
<ReactionAddons.Message channel={props.channel} message={parentMessage} reactionAddonType={'thread_parent_message'}></ReactionAddons.Message>
236237
</View>
237238
<Divider />
238239
{renderReplyCount(replyCountText)}
@@ -326,7 +327,7 @@ const styles = createStyleSheet({
326327
},
327328
reactionButtonContainer: {
328329
flexDirection: 'row',
329-
alignItems: 'center',
330+
height: 50,
330331
},
331332
reactionButton: {
332333
width: 30,

packages/uikit-react-native/src/hooks/useGroupChannelThreadMessages/useGroupChannelThreadMessages.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,8 @@ export const useGroupChannelThreadMessages = (
8080
const startingPoint = useRef(internalOptions.current?.startingPoint || Number.MAX_SAFE_INTEGER);
8181
startingPoint.current = internalOptions.current?.startingPoint || Number.MAX_SAFE_INTEGER;
8282

83-
let prevFetchSize = sbuConstants.collection.message.defaultLimit.prev;
84-
let nextFetchSize = sbuConstants.collection.message.defaultLimit.next;
85-
prevFetchSize = 1;
86-
nextFetchSize = 1;
83+
const prevFetchSize = sbuConstants.collection.message.defaultLimit.prev;
84+
const nextFetchSize = sbuConstants.collection.message.defaultLimit.next;
8785

8886
const logger = internalOptions.current.logger;
8987
const isFetching = useRef({ prev: false, next: false });

0 commit comments

Comments
 (0)