Skip to content

Commit a1f9d5b

Browse files
authored
fix: channel list stale latest messages (#3535)
## 🎯 Goal This PR is a port of [this change](#3534) to V9. ## 🛠 Implementation details <!-- Provide a description of the implementation --> ## 🎨 UI Changes <!-- Add relevant screenshots --> <details> <summary>iOS</summary> <table> <thead> <tr> <td>Before</td> <td>After</td> </tr> </thead> <tbody> <tr> <td> <!--<img src="" /> --> </td> <td> <!--<img src="" /> --> </td> </tr> </tbody> </table> </details> <details> <summary>Android</summary> <table> <thead> <tr> <td>Before</td> <td>After</td> </tr> </thead> <tbody> <tr> <td> <!--<img src="" /> --> </td> <td> <!--<img src="" /> --> </td> </tr> </tbody> </table> </details> ## 🧪 Testing <!-- Explain how this change can be tested (or why it can't be tested) --> ## ☑️ Checklist - [ ] I have signed the [Stream CLA](https://docs.google.com/forms/d/e/1FAIpQLScFKsKkAJI7mhCr7K9rEIOpqIDThrWxuvxnwUq2XkHyG154vQ/viewform) (required) - [ ] PR targets the `develop` branch - [ ] Documentation is updated - [ ] New code is tested in main example apps, including all possible scenarios - [ ] SampleApp iOS and Android - [ ] Expo iOS and Android
1 parent 7f78b39 commit a1f9d5b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

package/src/components/ChannelPreview/hooks/useChannelPreviewData.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const useChannelPreviewData = (
2323
) => {
2424
const [forceUpdate, setForceUpdate] = useState(0);
2525
const [lastMessage, setLastMessageInner] = useState<LastMessageType>(
26-
() => channel.state.messages[channel.state.messages.length - 1],
26+
() => channel.state.latestMessages[channel.state.latestMessages.length - 1],
2727
);
2828
const throttledSetLastMessage = useMemo(
2929
() =>
@@ -42,7 +42,7 @@ export const useChannelPreviewData = (
4242
const { forceUpdate: contextForceUpdate } = useChannelsContext();
4343
const channelListForceUpdate = forceUpdateOverride ?? contextForceUpdate;
4444

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

4848
const refreshUnreadCount = useMemo(

0 commit comments

Comments
 (0)