Skip to content

Commit

Permalink
fix: get lastMessage and latestMessagePreview from the latest message…
Browse files Browse the repository at this point in the history
… set in channel state
  • Loading branch information
MartinCupela committed Oct 11, 2024
1 parent eb66888 commit 251c053
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/ChannelPreview/ChannelPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/ChannelPreview/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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`] ||
Expand Down

0 comments on commit 251c053

Please sign in to comment.