stream-chat-react icon indicating copy to clipboard operation
stream-chat-react copied to clipboard

bug: The pinnedMessages data in useChannelStateContext does not represent the most recently pinned messages.

Open nganhuynh2002 opened this issue 9 months ago • 1 comments

Describe the bug

When I log the pinnedMessages data from useChannelStateContext, it only returns the first 10 pinned messages.

To Reproduce

Steps to reproduce the behavior:

When I log the pinnedMessages from useChannelStateContext(), it only returns the first 10 pinned messages (seemingly the oldest ones). const { pinnedMessages } = useChannelStateContext(); console.log(pinnedMessages, 'pinnedMessages')

Image

However, when I use channel.getPinnedMessages({ limit, offset }, { pinned_at: -1 }), I can fetch a longer list, and it's ordered by the most recently pinned messages (pinned_at descending). const pinedMessagesOtherPage = await channel.getPinnedMessages({ limit, offset: offset }, { pinned_at: -1 }); console.log('pinedMessagesOtherPage', pinedMessagesOtherPage.messages);

Image

Expected behavior

I would like pinnedMessages from useChannelStateContext() to reflect the same behavior — i.e., return the latest pinned messages, ideally ordered by pinned_at descending.

Screenshots pinnedMessages from useChannelStateContext() https://drive.google.com/file/d/1cDQf9bkAIFKs-6hqi18v4Zivh6bmuY1Q/view?usp=sharing

channel.getPinnedMessages https://drive.google.com/file/d/1nUpT7kIIvoLILuM0YdZrLCUh55M6HjU3/view?usp=sharing

Package version

  • stream-chat-react: 12.13.1
  • stream-chat-css: 5.7.2
  • stream-chat-js: 8.57.6

nganhuynh2002 avatar May 23 '25 07:05 nganhuynh2002

Hello @nganhuynh2002, those 10 pinned messages will probably be the first 10 messages you get with channel query. If you want to paginate pinned messages, then you need to use getPinnedMessages.

Feel free to describe your usecase - what you plan to do with the pinned messages array.

MartinCupela avatar Jun 30 '25 11:06 MartinCupela

Hello @MartinCupela, Thank you so much for the clarification!

nganhuynh2002 avatar Jul 01 '25 02:07 nganhuynh2002