chore: minor fix, add test

Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
Sahil Kumar
2023-07-18 16:35:35 +05:30
parent b6cc2e0899
commit 678fe4e807
2 changed files with 78 additions and 64 deletions
@@ -272,17 +272,14 @@ class StreamChatPersistenceClient extends ChatPersistenceClient {
channels.map((e) => getChannelStateByCid(e.cid)),
);
// Only sort the channel states if the channels are not already sorted.
if (channelStateSort == null) {
var comparator = _defaultChannelStateComparator;
if (channelStateSort != null && channelStateSort.isNotEmpty) {
comparator = _combineComparators(
channelStateSort.map((it) => it.comparator).withNullifyer,
);
}
channelStates.sort(comparator);
// Sort the channel states
var comparator = _defaultChannelStateComparator;
if (channelStateSort != null && channelStateSort.isNotEmpty) {
comparator = _combineComparators(
channelStateSort.map((it) => it.comparator).withNullifyer,
);
}
channelStates.sort(comparator);
final offset = paginationParams?.offset;
if (offset != null && offset > 0 && channelStates.isNotEmpty) {