Add channel reads pagination support #3613
Open
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.
🔗 Issue Links
Resolves: IOS-666
🎯 Goal
Add support for paginating channel reads for accurate read counts in large channels
📝 Summary
Important
Channel reads pagination is only supported through channel query endpoint while paginating members (slightly hidden feature)
Chat.loadMembers(with:)
andChat.loadMoreMembers(limit:)
which also paginates channel reads for these membersChannelQuery
to support setting pagination parameter for membersChannelDTO.reads
when saving channel payloads, only reset it when loading the first page of messages using the same endpoint (akaChatChannelController.synchronize
orChat.get(watch:)
)MessageDTO.readBy
for existing messages when saving channel payloads🛠 Implementation
We use
ChatMessage.readBy
for showing read counts for current user's messages. This property is updated usingChannelDTO.reads
(manual filtering). Channel reads are fetched based on requested channel members and by default up to 100 channel members are fetches (and reads for these users). If there are many members and we would like to get accurate channel reads, we would need to paginate members using channel query endpoint (members endpoint does not give channel reads).Chat
already incorporates member pagination. Before it was using /members endpoint, but this PR changes it to use the channel query endpoint.End result is that creating an instance of
Chat
and callingget(watch:)
will automatically give access to channel members fetched using the regular channel query call (default is 100 members and their channel reads). If we want more, we just need to callloadMoreMembers(limit:)
and we get next page of members and their channel read information.Open questions
🎨 Showcase
🧪 Manual Testing Notes
☑️ Contributor Checklist
docs-content
repo