Skip to content

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

Open
@nganhuynh2002

Description

@nganhuynh2002

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions