From 251c053b65e5ee11612a3cb932bb39c7786bb2cf Mon Sep 17 00:00:00 2001 From: martincupela Date: Fri, 11 Oct 2024 18:46:42 +0200 Subject: [PATCH] fix: get lastMessage and latestMessagePreview from the latest message set in channel state --- src/components/ChannelPreview/ChannelPreview.tsx | 2 +- src/components/ChannelPreview/utils.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/ChannelPreview/ChannelPreview.tsx b/src/components/ChannelPreview/ChannelPreview.tsx index 2ed12527c..d368ae3a4 100644 --- a/src/components/ChannelPreview/ChannelPreview.tsx +++ b/src/components/ChannelPreview/ChannelPreview.tsx @@ -137,7 +137,7 @@ export const ChannelPreview = < refreshUnreadCount(); const handleEvent = () => { - setLastMessage(channel.state.messages[channel.state.messages.length - 1]); + setLastMessage(channel.state.latestMessages[channel.state.latestMessages.length - 1]); refreshUnreadCount(); }; diff --git a/src/components/ChannelPreview/utils.tsx b/src/components/ChannelPreview/utils.tsx index a8cc5bd8c..1aaa77672 100644 --- a/src/components/ChannelPreview/utils.tsx +++ b/src/components/ChannelPreview/utils.tsx @@ -17,7 +17,7 @@ export const getLatestMessagePreview = < t: TranslationContextValue['t'], userLanguage: TranslationContextValue['userLanguage'] = 'en', ): string | JSX.Element => { - const latestMessage = channel.state.messages[channel.state.messages.length - 1]; + const latestMessage = channel.state.latestMessages[channel.state.latestMessages.length - 1]; const previewTextToRender = latestMessage?.i18n?.[`${userLanguage}_text` as `${TranslationLanguages}_text`] ||