diff --git a/packages/uikit-react-native/src/components/GroupChannelMessageRenderer/GroupChannelMessageParentMessage.tsx b/packages/uikit-react-native/src/components/GroupChannelMessageRenderer/GroupChannelMessageParentMessage.tsx index c1bee43e7..e89b5ca82 100644 --- a/packages/uikit-react-native/src/components/GroupChannelMessageRenderer/GroupChannelMessageParentMessage.tsx +++ b/packages/uikit-react-native/src/components/GroupChannelMessageRenderer/GroupChannelMessageParentMessage.tsx @@ -12,6 +12,7 @@ import { } from '@sendbird/uikit-react-native-foundation'; import { SendbirdFileMessage, + SendbirdGroupChannel, SendbirdMessage, SendbirdUserMessage, getFileIconFromMessageType, @@ -26,12 +27,13 @@ import { useLocalization, usePlatformService, useSendbirdChat } from '../../hook type Props = { variant: 'outgoing' | 'incoming'; + channel: SendbirdGroupChannel; message: SendbirdUserMessage | SendbirdFileMessage; childMessage: SendbirdUserMessage | SendbirdFileMessage; onPress?: (message: SendbirdMessage) => void; }; -const GroupChannelMessageParentMessage = ({ variant, message, childMessage, onPress }: Props) => { +const GroupChannelMessageParentMessage = ({ variant, channel, message, childMessage, onPress }: Props) => { const { currentUser } = useSendbirdChat(); const groupChannelPubSub = useContext(GroupChannelContexts.PubSub); const { select, colors, palette } = useUIKitTheme(); @@ -98,6 +100,10 @@ const GroupChannelMessageParentMessage = ({ variant, message, childMessage, onPr }; const parentMessageComponent = useIIFE(() => { + if (channel.messageOffsetTimestamp > parentMessage.createdAt) { + return renderMessageWithText(STRINGS.LABELS.MESSAGE_UNAVAILABLE); + } + switch (type) { case 'user': case 'user.opengraph': { diff --git a/packages/uikit-react-native/src/components/GroupChannelMessageRenderer/index.tsx b/packages/uikit-react-native/src/components/GroupChannelMessageRenderer/index.tsx index ed14a888b..2db680511 100644 --- a/packages/uikit-react-native/src/components/GroupChannelMessageRenderer/index.tsx +++ b/packages/uikit-react-native/src/components/GroupChannelMessageRenderer/index.tsx @@ -142,9 +142,10 @@ const GroupChannelMessageRenderer: GroupChannelProps['Fragment']['renderMessage' ) : null, parentMessage: shouldRenderParentMessage(message) ? ( ) : null, diff --git a/packages/uikit-react-native/src/localization/StringSet.type.ts b/packages/uikit-react-native/src/localization/StringSet.type.ts index b1cfc3000..d6256daed 100644 --- a/packages/uikit-react-native/src/localization/StringSet.type.ts +++ b/packages/uikit-react-native/src/localization/StringSet.type.ts @@ -250,6 +250,7 @@ export interface StringSet { parentMessage: SendbirdUserMessage | SendbirdFileMessage, currentUserId?: string, ) => string; + MESSAGE_UNAVAILABLE: string; USER_BAR_ME_POSTFIX: string; USER_BAR_OPERATOR: string; diff --git a/packages/uikit-react-native/src/localization/createBaseStringSet.ts b/packages/uikit-react-native/src/localization/createBaseStringSet.ts index 2021c3aa7..d4a8553bc 100644 --- a/packages/uikit-react-native/src/localization/createBaseStringSet.ts +++ b/packages/uikit-react-native/src/localization/createBaseStringSet.ts @@ -264,6 +264,7 @@ export const createBaseStringSet = ({ dateLocale, overrides }: StringSetCreateOp const receiverNickname = parent.sender.nickname || USER_NO_NAME; return `${reply.sender.userId !== currentUserId ? senderNickname : 'You'} replied to ${receiverNickname}`; }, + MESSAGE_UNAVAILABLE: 'Message unavailable', USER_BAR_ME_POSTFIX: ' (You)', USER_BAR_OPERATOR: 'Operator', diff --git a/sample/src/screens/uikit/SettingsScreen.tsx b/sample/src/screens/uikit/SettingsScreen.tsx index 2f1a319a5..d344c9d83 100644 --- a/sample/src/screens/uikit/SettingsScreen.tsx +++ b/sample/src/screens/uikit/SettingsScreen.tsx @@ -80,7 +80,7 @@ const SettingsScreen = () => { if (!photo) return; - await updateCurrentUserInfo(sdk.currentUser.nickname, photo); + await updateCurrentUserInfo(sdk.currentUser?.nickname, photo); }, }, { @@ -106,7 +106,7 @@ const SettingsScreen = () => { }); if (!files || !files[0]) return; - await updateCurrentUserInfo(sdk.currentUser.nickname, files[0]); + await updateCurrentUserInfo(sdk.currentUser?.nickname, files[0]); }, }, ],