Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(CLNP-3087): message threading #181

Open
wants to merge 81 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
1727b18
Implement GroupChannel thread.
OnestarLee May 9, 2024
0620e93
Clean up code
OnestarLee May 30, 2024
48c6727
Fixed lint
OnestarLee May 30, 2024
636a0b9
Update uikit-tools version
OnestarLee May 30, 2024
4f06819
Apply review
OnestarLee May 31, 2024
252b977
Fixed lint
OnestarLee May 31, 2024
a4861ac
Apply review
OnestarLee May 31, 2024
169b40e
Apply review
OnestarLee May 31, 2024
f2de01a
Apply review
OnestarLee May 31, 2024
528c209
Apply review
OnestarLee May 31, 2024
1af97bf
Changed threadReplySelectType to thread
OnestarLee May 31, 2024
c793d25
Apply review
OnestarLee May 31, 2024
a915920
chore: update parent message reactions UI
bang9 May 31, 2024
6a9b220
chore: add applyReactionEvent to reaction addon
bang9 May 31, 2024
0e40c3d
chore: resolve message gap issue in thread fragment
bang9 May 31, 2024
08d4a54
Apply review
OnestarLee May 31, 2024
514efc1
chore: disable message grouping if reply or thread message
bang9 May 31, 2024
9ae9a63
chore: update message grouping logic
bang9 May 31, 2024
431454b
chore: add color to more button.
OnestarLee May 31, 2024
d6732fd
chore: fixed lint.
OnestarLee May 31, 2024
e494858
chore: update parent message properly
bang9 May 31, 2024
c519bbb
chore: improve thread message list.
OnestarLee Jun 1, 2024
db2c418
Merge remote-tracking branch 'origin/feat/message-threading' into fea…
OnestarLee Jun 1, 2024
03ae8a1
chore: improve thread message list.
OnestarLee Jun 1, 2024
fba519d
chore: change version for sample test.
OnestarLee Jun 1, 2024
f4753cd
chore: fixed not going to channel when clicking title.
OnestarLee Jun 4, 2024
8bd34b7
chore: fixed to show 'Reply to thread' in the placeholder when there…
OnestarLee Jun 4, 2024
7f2b70a
chore: removed NewMessageButton, ScrollToBottomButton in thread.
OnestarLee Jun 4, 2024
b61954b
chore: fixed usernames are not displaying in thread.
OnestarLee Jun 4, 2024
1e8b68e
chore: fixed an issue where it is possible to enter an invalid thread.
OnestarLee Jun 4, 2024
54e37b6
chore: fixed an issue where incorrect sentences are displayed when re…
OnestarLee Jun 4, 2024
805c80f
chore: removed NewMessageButton, ScrollToBottomButton in thread.
OnestarLee Jun 4, 2024
dabeb0b
Implement GroupChannel thread.
OnestarLee May 9, 2024
4144be4
Clean up code
OnestarLee May 30, 2024
e061099
Fixed lint
OnestarLee May 30, 2024
2baa437
Update uikit-tools version
OnestarLee May 30, 2024
95e61d5
Apply review
OnestarLee May 31, 2024
c532fdd
Fixed lint
OnestarLee May 31, 2024
a6238f8
Apply review
OnestarLee May 31, 2024
7d741ca
Apply review
OnestarLee May 31, 2024
40c2c69
Apply review
OnestarLee May 31, 2024
1d71dee
Apply review
OnestarLee May 31, 2024
9f9f455
Changed threadReplySelectType to thread
OnestarLee May 31, 2024
bbf42aa
Apply review
OnestarLee May 31, 2024
4d8e78e
chore: update parent message reactions UI
bang9 May 31, 2024
92f56e1
chore: add applyReactionEvent to reaction addon
bang9 May 31, 2024
6462d28
chore: resolve message gap issue in thread fragment
bang9 May 31, 2024
50bd116
Apply review
OnestarLee May 31, 2024
8c7de1f
chore: disable message grouping if reply or thread message
bang9 May 31, 2024
fc4da02
chore: update message grouping logic
bang9 May 31, 2024
14c01e2
chore: add color to more button.
OnestarLee May 31, 2024
918d39c
chore: fixed lint.
OnestarLee May 31, 2024
9701a86
chore: improve thread message list.
OnestarLee Jun 1, 2024
cd5e18d
chore: update parent message properly
bang9 May 31, 2024
a0f26e3
chore: improve thread message list.
OnestarLee Jun 1, 2024
7e80e69
chore: changed replyType to quote_reply
OnestarLee Jun 5, 2024
9d55ef1
Merge remote-tracking branch 'refs/remotes/origin/feat/message-thread…
OnestarLee Jun 14, 2024
742180b
chore: fixed inverted no message.
OnestarLee Jun 14, 2024
c2bd6c9
chore: update reply count format to display 99+ replies for counts of…
OnestarLee Jun 14, 2024
5147852
chore: fixed issue with mention suggestion list sorting
OnestarLee Jun 17, 2024
f7a4334
chore: fixed issue with file upload size limit exceeded
OnestarLee Jun 18, 2024
9fe3a0f
chore: fixed issue with file upload size limit exceeded
OnestarLee Jun 18, 2024
5390017
chore: add voice message status manager
OnestarLee Jun 21, 2024
226fdb6
chore: add voice message status manager
OnestarLee Jun 23, 2024
ceae6b8
chore: change scroll timeout
OnestarLee Jun 23, 2024
4e797aa
chore: organize code
OnestarLee Jun 23, 2024
7b9072c
chore: fixed scroll issue
OnestarLee Jun 23, 2024
1b59c86
chore: apply review.
OnestarLee Jun 28, 2024
f906482
chore: update note
bang9 Jun 28, 2024
6a07692
chore: apply review.
OnestarLee Jun 28, 2024
59c1b2d
Merge remote-tracking branch 'origin/feat/message-threading-qa' into …
OnestarLee Jun 28, 2024
484199d
chore: apply review when clicking the subtitle
OnestarLee Jul 3, 2024
a7d75a7
chore: apply review when clicking the subtitle
OnestarLee Jul 3, 2024
95c4848
Merge pull request #182 from sendbird/feat/message-threading-qa
OnestarLee Jul 3, 2024
10c9693
chore: apply review
OnestarLee Jul 3, 2024
c1a345d
chore: apply review
OnestarLee Jul 3, 2024
67bd30d
chore: apply review when clicking the subtitle
OnestarLee Jul 4, 2024
5c95845
chore: apply review when clicking the subtitle
OnestarLee Jul 8, 2024
7ce5584
chore: apply review when clicking the subtitle
OnestarLee Jul 8, 2024
cff851c
chore: apply review when clicking the subtitle
OnestarLee Jul 8, 2024
5ef3876
chore: apply review when clicking the subtitle
OnestarLee Jul 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply review
  • Loading branch information
OnestarLee committed Jun 13, 2024
commit 95e61d5d615c4c0d3ef24fb887b616f6232f3385
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ MessageContainer.Incoming = function MessageContainerIncoming({
</Box>
</Box>
</Box>
<Box marginLeft={40} marginTop={4} flexDirection={'row'} height={20}>
{replyInfo}
</Box>
{replyInfo}
bang9 marked this conversation as resolved.
Show resolved Hide resolved
</Box>
);
};
Expand Down Expand Up @@ -102,9 +100,7 @@ MessageContainer.Outgoing = function MessageContainerOutgoing({
</Box>
<Box style={styles.bubble}>{children}</Box>
</Box>
<Box marginTop={4} flexDirection={'row-reverse'} height={20}>
{replyInfo}
</Box>
{replyInfo}
</Box>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const SendInput = forwardRef<RNTextInput, SendInputProps>(function SendInput(
channel,
messageToReply,
setMessageToReply,
messageToThread,
messageForThread,
},
ref,
) {
Expand All @@ -69,22 +69,25 @@ const SendInput = forwardRef<RNTextInput, SendInputProps>(function SendInput(
visible: voiceMessageInputVisible,
setVisible: setVoiceMessageInputVisible,
} = useDeferredModalState();

const messageReplyParams = useIIFE(() => {
const { groupChannel } = sbOptions.uikit;
if (
!channel.isGroupChannel() ||
groupChannel.channel.replyType === 'none' ||
(groupChannel.channel.replyType === 'quote_reply' && !messageToReply) ||
(groupChannel.channel.replyType === 'thread' && !messageToThread)
) {
return {};

if (channel.isGroupChannel()) {
if (groupChannel.channel.replyType === 'quote_reply' && messageToReply) {
return {
parentMessageId: messageToReply.messageId,
isReplyToChannel: true,
};
} else if (groupChannel.channel.replyType === 'thread' && messageForThread) {
return {
parentMessageId: messageForThread.messageId,
isReplyToChannel: true,
};
}
}

return {
parentMessageId: messageToReply?.messageId ?? messageToThread?.messageId,
isReplyToChannel: true,
};

return {};
});

const messageMentionParams = useIIFE(() => {
Expand Down Expand Up @@ -161,7 +164,7 @@ const SendInput = forwardRef<RNTextInput, SendInputProps>(function SendInput(
if (inputFrozen) return STRINGS.LABELS.CHANNEL_INPUT_PLACEHOLDER_DISABLED;
if (inputDisabled) return STRINGS.LABELS.CHANNEL_INPUT_PLACEHOLDER_DISABLED;
if (messageToReply) return STRINGS.LABELS.CHANNEL_INPUT_PLACEHOLDER_REPLY;
if (messageToThread) return STRINGS.LABELS.CHANNEL_INPUT_PLACEHOLDER_THREAD;
if (messageForThread) return STRINGS.LABELS.CHANNEL_INPUT_PLACEHOLDER_THREAD;

return STRINGS.LABELS.CHANNEL_INPUT_PLACEHOLDER_ACTIVE;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export type ChannelInputProps = {
// reply - only available on group channel
messageToReply?: undefined | SendbirdUserMessage | SendbirdFileMessage;
setMessageToReply?: (message?: undefined | SendbirdUserMessage | SendbirdFileMessage) => void;
messageToThread?: undefined | SendbirdUserMessage | SendbirdFileMessage;
messageForThread?: undefined | SendbirdUserMessage | SendbirdFileMessage;

// mention
SuggestedMentionList?: CommonComponent<SuggestedMentionListProps>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,10 @@ const useCreateMessagePressActions = <T extends SendbirdGroupChannel | SendbirdO
sheetItems.push(menu.delete(message));
}
if (channel.isGroupChannel()) {
if (channel.isGroupChannel()) {
if (sbOptions.uikit.groupChannel.channel.replyType === 'thread' && onReplyInThreadMessage !== undefined) {
sheetItems.push(menu.replyInThread(message));
} else if (sbOptions.uikit.groupChannel.channel.replyType === 'quote_reply') {
sheetItems.push(menu.reply(message));
}
if (sbOptions.uikit.groupChannel.channel.replyType === 'thread' && onReplyInThreadMessage !== undefined) {
sheetItems.push(menu.replyInThread(message));
} else if (sbOptions.uikit.groupChannel.channel.replyType === 'quote_reply') {
sheetItems.push(menu.reply(message));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const AVATAR_LIMIT = 5;
type Props = {
channel: SendbirdGroupChannel;
message: SendbirdMessage;
variant: 'outgoing' | 'incoming';
onPress?: (message: SendbirdUserMessage | SendbirdFileMessage) => void;
};

Expand Down Expand Up @@ -47,38 +48,50 @@ const createRepliedUserAvatars = (mostRepliedUsers: User[]) => {
});
};

const GroupChannelMessageReplyInfo = ({ channel, message, onPress }: Props) => {
const GroupChannelMessageReplyInfo = ({ channel, message, variant, onPress }: Props) => {
const { STRINGS } = useLocalization();
const { select, palette } = useUIKitTheme();

if (!channel || !message.threadInfo || !message.threadInfo.replyCount) return null;

const replyCountText = STRINGS.GROUP_CHANNEL_THREAD.REPLAY_POSTFIX(message.threadInfo.replyCount || 0);
const replyCountText = STRINGS.GROUP_CHANNEL_THREAD.REPLAY_COUNT(message.threadInfo.replyCount || 0);
const onPressReply = () => {
onPress?.(message as SendbirdUserMessage | SendbirdFileMessage);
};

const renderAvatars = createRepliedUserAvatars(message.threadInfo.mostRepliedUsers);
bang9 marked this conversation as resolved.
Show resolved Hide resolved

const containerStyle = variant === 'incoming' ? styles.incomingContainer : styles.outgoingContainer;
return (
<PressBox onPress={onPressReply} style={styles.messageContainer}>
<Box style={containerStyle}>
<PressBox onPress={onPressReply} style={styles.replyContainer}>
{renderAvatars}
<Text caption3 color={select({ light: palette.primary300, dark: palette.primary200 })} style={styles.message}>
<Text caption3 color={select({ light: palette.primary300, dark: palette.primary200 })} style={styles.replyText}>
{replyCountText}
</Text>
</PressBox>
</Box>
);
};

const styles = createStyleSheet({
container: {
incomingContainer: {
marginTop: 4,
justifyContent: 'flex-start',
flexDirection: 'row',
height: 20,
},
outgoingContainer: {
marginTop: 4,
flexDirection: 'row',
justifyContent: 'flex-end',
height: 20,
},
messageContainer: {
replyContainer: {
marginLeft: 40,
flexDirection: 'row',
alignItems: 'flex-end',
alignItems: 'center',
},
message: {
replyText: {
marginHorizontal: 4,
},
avatarContainer: {
Expand All @@ -87,8 +100,9 @@ const styles = createStyleSheet({
height: 20,
},
avatar: {
width: '100%',
height: '100%',
width: 20,
height: 20,
borderRadius: 10,
},
avatarOverlay: {
position: 'absolute',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ const GroupChannelMessageRenderer: GroupChannelProps['Fragment']['renderMessage'
return null;
});

const renderReplyInfo = useIIFE(() => {
const replyInfo = useIIFE(() => {
if (sbOptions.uikit.groupChannel.channel.replyType !== 'thread') return null;
if (!channel || !message.threadInfo || !message.threadInfo.replyCount) return null;
return <GroupChannelMessageReplyInfo channel={channel} message={message} onPress={onReplyInThreadMessage} />;
return <GroupChannelMessageReplyInfo channel={channel} message={message} variant={variant} onPress={onReplyInThreadMessage} />;
});

const resetPlayer = async () => {
Expand Down Expand Up @@ -154,7 +154,7 @@ const GroupChannelMessageRenderer: GroupChannelProps['Fragment']['renderMessage'
groupedWithPrev: groupWithPrev,
groupedWithNext: groupWithNext,
children: reactionChildren,
replyInfo: renderReplyInfo,
replyInfo: replyInfo,
sendingStatus: isMyMessage(message, currentUser?.userId) ? (
<GroupChannelMessageOutgoingStatus channel={channel} message={message} />
) : null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const GroupChannelThreadInput = ({ inputDisabled, ...props }: GroupChannelThread
channel={channel}
messageToEdit={messageToEdit}
setMessageToEdit={setMessageToEdit}
messageToThread={parentMessage}
messageForThread={parentMessage}
keyboardAvoidOffset={keyboardAvoidOffset}
inputMuted={chatAvailableState.muted}
inputFrozen={chatAvailableState.frozen}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { format } from 'date-fns';
import React, { useContext } from 'react';
import { TouchableOpacity, View } from 'react-native';

Expand Down Expand Up @@ -48,8 +47,8 @@ const GroupChannelThreadParentMessageInfo = (props: GroupChannelThreadProps['Par
const { sbOptions } = useSendbirdChat();

const nickName = parentMessage.sender?.nickname || STRINGS.LABELS.USER_NO_NAME;
const messageTimestamp = format(new Date(parentMessage.updatedAt), "MMM dd 'at' h:mm a");
const replyCountText = STRINGS.GROUP_CHANNEL_THREAD.REPLAY_POSTFIX(parentMessage.threadInfo?.replyCount || 0);
const messageTimestamp = STRINGS.GROUP_CHANNEL_THREAD.PARENT_MESSAGE_TIME(parentMessage);
const replyCountText = STRINGS.GROUP_CHANNEL_THREAD.REPLAY_COUNT(parentMessage.threadInfo?.replyCount || 0);
const createMessagePressActions = useCreateMessagePressActions({
channel: props.channel,
currentUserId: props.currentUserId,
Expand Down Expand Up @@ -102,7 +101,7 @@ const GroupChannelThreadParentMessageInfo = (props: GroupChannelThreadProps['Par
channel={props.channel}
message={parentMessage}
reactionAddonType={'thread_parent_message'}
></ReactionAddons.Message>
/>
</View>
);
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { createContext, useCallback, useRef, useState } from 'react';
import React, { createContext, useRef, useState } from 'react';
import type { FlatList } from 'react-native';

import {
Expand Down Expand Up @@ -70,7 +70,7 @@ export const GroupChannelThreadContextsProvider: GroupChannelThreadModule['Provi
parentMessage,
keyboardAvoidOffset,
messageToEdit: messageToEdit,
setMessageToEdit: useCallback((message) => setMessageToEdit(message), []),
setMessageToEdit,
}}
>
<GroupChannelThreadContexts.PubSub.Provider value={groupChannelThreadPubSub}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ export interface StringSet {
MESSAGE_BUBBLE_EDITED_POSTFIX: string;
MESSAGE_BUBBLE_UNKNOWN_TITLE: (message: SendbirdMessage) => string;
MESSAGE_BUBBLE_UNKNOWN_DESC: (message: SendbirdMessage) => string;

REPLAY_POSTFIX: (replyCount: number) => string;

PARENT_MESSAGE_TIME: (message: SendbirdMessage, locale?: Locale) => string;
REPLAY_COUNT: (replyCount: number) => string;

/** GroupChannelThread > Suggested mention list */
MENTION_LIMITED: (mentionLimit: number) => string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Locale } from 'date-fns';

import type { PartialDeep } from '@sendbird/uikit-utils';
import { getThreadParentMessageTimeFormat, PartialDeep, SendbirdMessage } from '@sendbird/uikit-utils';
import {
getDateSeparatorFormat,
getGroupChannelPreviewTime,
Expand Down Expand Up @@ -139,8 +139,9 @@ export const createBaseStringSet = ({ dateLocale, overrides }: StringSetCreateOp
MESSAGE_BUBBLE_EDITED_POSTFIX: ' (edited)',
MESSAGE_BUBBLE_UNKNOWN_TITLE: () => '(Unknown message type)',
MESSAGE_BUBBLE_UNKNOWN_DESC: () => 'Cannot read this message.',

REPLAY_POSTFIX: (replyCount: number) => getReplyCountFormat(replyCount),

PARENT_MESSAGE_TIME: (message: SendbirdMessage, locale?: Locale) => getThreadParentMessageTimeFormat(new Date(message.createdAt), locale ?? dateLocale),
REPLAY_COUNT: (replyCount: number) => getReplyCountFormat(replyCount),

MENTION_LIMITED: (mentionLimit) => `You can have up to ${mentionLimit} mentions per message.`,
...overrides?.GROUP_CHANNEL_THREAD,
Expand Down
11 changes: 11 additions & 0 deletions packages/uikit-utils/src/ui-format/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,14 @@ export const getReplyCountFormat = (replyCount: number) => {

return '';
};

/**
* Thread parent message time format
*
* @param {Date} date
* @param {Locale} [locale]
* @returns {string}
* */
export const getThreadParentMessageTimeFormat = (date: Date, locale?: Locale): string => {
return format(date, "MMM dd 'at' h:mm a", { locale });
};