fix: channels sorting with predefined filters#1747
Open
isekovanic wants to merge 3 commits into
Open
Conversation
Contributor
|
Size Change: +2.31 kB (+0.6%) Total Size: 387 kB 📦 View Changed
|
szuperaz
approved these changes
May 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CLA
Description of the changes, What, Why and How?
This PR fixes ChannelManager list mutation behavior for
queryChannels()calls that useoptions.predefined_filter.Previously, predefined filter requests were sent correctly, but
queryChannelsRequest()returned onlydata.channels, so the top levelpredefined_filtermetadata from/channelswas discarded. That metadata contains the backend resolved effective filter and sort. Without it,ChannelManagercontinued using only the original caller inputs for WS-driven list mutations.For predefined queries, the caller input can be intentionally empty:
while the backend may resolve the actual list semantics to:
Because
ChannelManagerdid not have access to that resolved metadata, events such asmessage.new,notification.message_new,channel.visibleandmember.updatedbehaved as if archived and pinned handling was disabled. That could allow archived channels to be promoted into non-archived lists, unarchived channels to be promoted into archived lists or pinned channels to move whenpinned_atsorting should keep them stable.This PR adds an explicit full response query path:
The existing
queryChannelsRequest()keeps its current behavior and still returns only raw channel API responses.queryChannels()also keeps returningChannel[]normally. When called with:queryChannels()returns the full query response with hydrated channels:ChannelManagerthen uses this internalwithResponsepath so it can readresponse.predefined_filterwithout changing the default publicqueryChannels()behaviour.ChannelManagernow keeps the original request inputs separate from the backend resolved response metadata through 2 new state properties:responseFiltersresponseSortThe original
filters,sortandoptionsremain the source of truth forpagination,loadNext(), retries, offline DB query context and preserving the existing pagination state semantics. The newresponseFiltersandresponseSortare used only for local WS driven channel list mutation decisions (i.e when do we promote achanneland how).The predefined filter response
sortshape is:but
ChannelManagerutilities expectChannelSort:so we also convert the response sort before storing it as
responseSort.I also considered using the existing
channels.queriedevent to pass this metadata toChannelManager, however I decided against that for now becausechannels.queriedisclientwide and not scoped to a specificChannelManagerrequest. Without a request/correlation ID, multipleChannelManagersor directclient.queryChannels()calls could very well race and attach resolved metadata to the wrong list. The metadata is also local list state, not general client state and event ordering would be fragile becauseChannelManagerupdates pagination after its query resolves. The explicitwithResponsereturn path keeps the data tied directly to the request that produced it.Changelog