Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: channel list not updated after pinning a channel #2595

Closed
michalvankodev opened this issue Jan 2, 2025 · 3 comments
Closed

bug: channel list not updated after pinning a channel #2595

michalvankodev opened this issue Jan 2, 2025 · 3 comments
Labels
bug Something isn't working status: unconfirmed

Comments

@michalvankodev
Copy link

Describe the bug

After pinning a channel the channel list is not re-sorted and it doesn't show newly pinned channel within the group of other pinned channels.

To Reproduce

Steps to reproduce the behavior:

  1. Query channels with sort:
  const sort: ChannelSort = {
    pinned_at: -1,
    last_updated_at: -1,
    last_message_at: -1,
  };
  1. Pin channel that is not yet pinned from the bottom of the queried channels
  2. Pinned channel's state is updated but the channel list is not updated according to the sorting.

Expected behavior

Channel list should be sorted according to the sort rules passed and should be updated when channel is updated

Screenshots

image

Best friends group is pinned but it was not attached to the group of pinned channels

Package version

  • stream-chat-react: 12.8.1

If I should apply sorting manually is there a way how to just force update?

@michalvankodev michalvankodev added bug Something isn't working status: unconfirmed labels Jan 2, 2025
@arnautov-anton
Copy link
Contributor

Hey, @michalvankodev, thank you for submitting this issue.

The problem is in the sort object - when pulling data from database you sort by keys, the order of the keys is important. That being said - our SDK allows passing sort as an object - it's meant to be used with single key only. This object gets re-constructed client-level to an array before being sent to the BE for further processing. To ensure the proper order of the keys is delivered to the BE for processing we recommend passing an array to the sort property of the ChannelList, only in this shape the runtime re-sorting of the channels (with consideration to pinned channels) is enabled:

const sort: ChannelSort = [
    { pinned_at: -1 },
    { last_updated_at: -1 },
    { last_message_at: -1 },
 ];

@michalvankodev
Copy link
Author

Thanks @arnautov-anton. This has resolved the issue. It would be worth mentioning this in the documentation instead of the examples provided.

@arnautov-anton
Copy link
Contributor

Definitely, it's on our list to add this limitation to the documentation. I'll also explore an option to allow such objects to be considered as well as it seems that for...in accesses object properties chronologically as they were created - we can check if the key appears to be first and enable the expected behavior in such case as well as we can reliably tell that the array to be sent to the BE will be constructed deterministically.

arnautov-anton added a commit that referenced this issue Jan 24, 2025
### 🎯 Goal

Adjust certain conditions to match behavior of the RN implementation,
add missing handler for the `notification.added_to_channel`.

#### Notable Changes
- `notification.added_to_channel` is being handled properly (considers
pinned channels)
- if `sort` is an object and `pinned_at` is first in chronological order
of property creation `{ pinned_at: 1 | -1 }` then pinned channels are
considered
(#2595 (comment))

Related PR: GetStream/stream-chat-js#1430
github-actions bot pushed a commit that referenced this issue Jan 27, 2025
## [12.9.0](v12.8.2...v12.9.0) (2025-01-27)

### Bug Fixes

* channel-pinning related improvements ([#2602](#2602)) ([9f41a4c](9f41a4c)), closes [/github.com//issues/2595#issuecomment-2569118691](https://github.com/GetStream//github.com/GetStream/stream-chat-react/issues/2595/issues/issuecomment-2569118691)
* import execSync ([#2616](#2616)) ([3801375](3801375))

### Features

* add prop disabled to ChatAutoComplete props ([#2617](#2617)) ([8b686fe](8b686fe))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working status: unconfirmed
Projects
None yet
Development

No branches or pull requests

2 participants