Skip to content
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const useChannelPreviewData = (
) => {
const [forceUpdate, setForceUpdate] = useState(0);
const [lastMessage, setLastMessageInner] = useState<LastMessageType>(
() => channel.state.messages[channel.state.messages.length - 1],
() => channel.state.latestMessages[channel.state.latestMessages.length - 1],
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been wrong for years it seems, as we found with @MartinCupela . It's a pretty nasty edge case where if your first load of a channel is to a message in a different message set than the latest one (i.e through a deeplink let's say), the channel list would basically show the last message of that page only (and not the actual latest message in the channel).

);
const throttledSetLastMessage = useMemo(
() =>
Expand All @@ -44,7 +44,7 @@ export const useChannelPreviewData = (
const { forceUpdate: contextForceUpdate } = useChannelsContext();
const channelListForceUpdate = forceUpdateOverride ?? contextForceUpdate;

const channelLastMessage = channel.lastMessage();
const channelLastMessage = channel.state.latestMessages[channel.state.latestMessages.length - 1];
const channelLastMessageString = `${channelLastMessage?.id}${channelLastMessage?.updated_at}`;

const refreshUnreadCount = useMemo(
Expand Down
Loading