Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/stream_chat_persistence/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Upcoming

- Fixed an issue in the `getChannelStates` method where `paginationParams.offset` greater than the
available channel count would cause an exception. The method now properly handles this edge case.

## 9.9.0

- Added support for `User.teamsRole` field.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,15 @@
channelStates.sort(channelStateSort.compare);
}

final offset = paginationParams?.offset;
if (offset != null && offset > 0 && channelStates.isNotEmpty) {
channelStates.removeRange(0, offset);
// Apply offset
if (paginationParams?.offset case final paginationOffset?) {
final clampedOffset = paginationOffset.clamp(0, channelStates.length);
channelStates.removeRange(0, clampedOffset);

Check warning on line 287 in packages/stream_chat_persistence/lib/src/stream_chat_persistence_client.dart

View check run for this annotation

Codecov / codecov/patch

packages/stream_chat_persistence/lib/src/stream_chat_persistence_client.dart#L285-L287

Added lines #L285 - L287 were not covered by tests
}

if (paginationParams?.limit != null) {
return channelStates.take(paginationParams!.limit).toList();
// Apply limit
if (paginationParams?.limit case final paginationLimit?) {
return channelStates.take(paginationLimit).toList();

Check warning on line 292 in packages/stream_chat_persistence/lib/src/stream_chat_persistence_client.dart

View check run for this annotation

Codecov / codecov/patch

packages/stream_chat_persistence/lib/src/stream_chat_persistence_client.dart#L291-L292

Added lines #L291 - L292 were not covered by tests
}

return channelStates;
Expand Down
Loading