fix(persistence,llc,core,ui): deprecated sort, add channelStateSort s… (#1366)

* fix(persistence,llc,core,ui): deprecated sort, add channelStateSort sorting the channels offline using the state

* update changelogs

* update tests

* remove deprecated test

* change threashold

* minor fixes

* remove tests

* fix(persistence): minor changes.

Signed-off-by: xsahil03x <[email protected]>

Signed-off-by: xsahil03x <[email protected]>
Co-authored-by: Sahil Kumar <[email protected]>
This commit is contained in:
Salvatore Giordano
2022-10-25 17:07:02 +02:00
committed by GitHub
co-authored by Sahil Kumar
parent 5784c53e6b
commit d09d3817b5
19 changed files with 131 additions and 55 deletions
+2
View File
@@ -8,6 +8,8 @@
- Remove disposed channel clients from the client state.
- Deprecated the `sort` parameter in `queryChannels` in favor of `channelStateSort`.
## 5.0.0
- Included the changes from version [4.5.0](#450).
@@ -517,7 +517,10 @@ class StreamChatClient {
/// Requests channels with a given query.
Stream<List<Channel>> queryChannels({
Filter? filter,
List<SortOption<ChannelModel>>? sort,
@Deprecated('''
sort has been deprecated.
Please use channelStateSort instead.''') List<SortOption<ChannelModel>>? sort,
List<SortOption<ChannelState>>? channelStateSort,
bool state = true,
bool watch = true,
bool presence = false,
@@ -547,7 +550,9 @@ class StreamChatClient {
} else {
final channels = await queryChannelsOffline(
filter: filter,
// ignore: deprecated_member_use_from_same_package
sort: sort,
channelStateSort: channelStateSort,
paginationParams: paginationParams,
);
if (channels.isNotEmpty) yield channels;
@@ -555,7 +560,7 @@ class StreamChatClient {
try {
final newQueryChannelsFuture = queryChannelsOnline(
filter: filter,
sort: sort,
sort: channelStateSort ?? sort,
state: state,
watch: watch,
presence: presence,
@@ -598,7 +603,7 @@ class StreamChatClient {
/// Requests channels with a given query from the API.
Future<List<Channel>> queryChannelsOnline({
Filter? filter,
List<SortOption<ChannelModel>>? sort,
List<SortOption>? sort,
bool state = true,
bool watch = true,
bool presence = false,
@@ -672,12 +677,17 @@ class StreamChatClient {
/// Requests channels with a given query from the Persistence client.
Future<List<Channel>> queryChannelsOffline({
Filter? filter,
List<SortOption<ChannelModel>>? sort,
@Deprecated('''
sort has been deprecated.
Please use channelStateSort instead.''') List<SortOption<ChannelModel>>? sort,
List<SortOption<ChannelState>>? channelStateSort,
PaginationParams paginationParams = const PaginationParams(),
}) async {
final offlineChannels = (await _chatPersistenceClient?.getChannelStates(
filter: filter,
// ignore: deprecated_member_use_from_same_package
sort: sort,
channelStateSort: channelStateSort,
paginationParams: paginationParams,
)) ??
[];
@@ -3,7 +3,6 @@ import 'dart:convert';
import 'package:stream_chat/src/core/api/requests.dart';
import 'package:stream_chat/src/core/api/responses.dart';
import 'package:stream_chat/src/core/http/stream_http_client.dart';
import 'package:stream_chat/src/core/models/channel_model.dart';
import 'package:stream_chat/src/core/models/channel_state.dart';
import 'package:stream_chat/src/core/models/event.dart';
import 'package:stream_chat/src/core/models/filter.dart';
@@ -51,7 +50,7 @@ class ChannelApi {
/// Requests channels with a given query from the API.
Future<QueryChannelsResponse> queryChannels({
Filter? filter,
List<SortOption<ChannelModel>>? sort,
List<SortOption>? sort,
int? memberLimit,
int? messageLimit,
bool state = true,
@@ -94,7 +94,10 @@ abstract class ChatPersistenceClient {
/// for filtering out states.
Future<List<ChannelState>> getChannelStates({
Filter? filter,
List<SortOption<ChannelModel>>? sort,
@Deprecated('''
sort has been deprecated.
Please use channelStateSort instead.''') List<SortOption<ChannelModel>>? sort,
List<SortOption<ChannelState>>? channelStateSort,
PaginationParams? paginationParams,
});
@@ -618,7 +618,7 @@ void main() {
when(() => persistence.getChannelStates(
filter: any(named: 'filter'),
sort: any(named: 'sort'),
channelStateSort: any(named: 'channelStateSort'),
paginationParams: any(named: 'paginationParams'),
)).thenAnswer((_) async => persistentChannelStates);
@@ -674,7 +674,7 @@ void main() {
verify(() => persistence.getChannelStates(
filter: any(named: 'filter'),
sort: any(named: 'sort'),
channelStateSort: any(named: 'channelStateSort'),
paginationParams: any(named: 'paginationParams'),
)).called(1);
@@ -715,7 +715,7 @@ void main() {
when(() => persistence.getChannelStates(
filter: any(named: 'filter'),
sort: any(named: 'sort'),
channelStateSort: any(named: 'channelStateSort'),
paginationParams: any(named: 'paginationParams'),
)).thenAnswer((_) async => persistentChannelStates);
@@ -757,7 +757,7 @@ void main() {
verify(() => persistence.getChannelStates(
filter: any(named: 'filter'),
sort: any(named: 'sort'),
channelStateSort: any(named: 'channelStateSort'),
paginationParams: any(named: 'paginationParams'),
)).called(1);
@@ -56,7 +56,10 @@ class TestPersistenceClient extends ChatPersistenceClient {
@override
Future<List<ChannelState>> getChannelStates(
{Filter? filter,
List<SortOption<ChannelModel>>? sort,
@Deprecated('''
sort has been deprecated.
Please use channelStateSort instead.''') List<SortOption<ChannelModel>>? sort,
List<SortOption<ChannelState>>? channelStateSort,
PaginationParams? paginationParams}) =>
throw UnimplementedError();