From 0b619e57a8025276fd68424e197fe5b16f979df9 Mon Sep 17 00:00:00 2001 From: Tyler Jeong Date: Tue, 12 Dec 2023 11:16:32 +0900 Subject: [PATCH] Add 4.1.2. --- CHANGELOG.md | 12 ++ README.md | 2 +- lib/sendbird_chat_sdk.dart | 1 - lib/src/internal/main/chat/chat.dart | 2 +- .../main/model/group_channel_filter.dart | 106 +++++++++++++++++ .../main/model}/group_channel_filter.g.dart | 6 +- .../group_channel_list_request.dart | 2 +- .../public_group_channel_list_request.dart | 2 +- .../channel/base_channel/base_channel.dart | 46 +++++--- .../channel/feed_channel/feed_channel.dart | 107 +++++++++++------- .../model/channel/group_channel_filter.dart | 93 --------------- .../main/model/reaction/reaction_event.dart | 9 +- .../main/model/reaction/reaction_event.g.dart | 12 +- .../channel/group_channel_list_query.dart | 14 ++- .../public_group_channel_list_query.dart | 14 ++- pubspec.yaml | 2 +- 16 files changed, 262 insertions(+), 168 deletions(-) create mode 100644 lib/src/internal/main/model/group_channel_filter.dart rename lib/src/{public/main/model/channel => internal/main/model}/group_channel_filter.g.dart (93%) delete mode 100644 lib/src/public/main/model/channel/group_channel_filter.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index b864faf3..1b572fc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## v4.1.2 (Dec 12, 2023) + +### Features +- Added `createdBefore` and `createdAfter` in `GroupChannelListQuery` and `PublicGroupChannelListQuery` +- Added `markAsClicked()` in `FeedChannel` +- Replaced `markAsReadBy()` with `markAsRead()` in `FeedChannel` + +### Improvements +- Fix the bugs regarding FeedChannel +- Fix the bugs regarding ReactionEvent +- Improved stability + ## v4.1.1 (Nov 8, 2023) ### Improvements diff --git a/README.md b/README.md index 8bd7130e..657dd064 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Before installing Sendbird Chat SDK, you need to create a Sendbird application o ```yaml dependencies: - sendbird_chat_sdk: ^4.1.1 + sendbird_chat_sdk: ^4.1.2 ``` - Run `flutter pub get` command in your project directory. diff --git a/lib/sendbird_chat_sdk.dart b/lib/sendbird_chat_sdk.dart index ac152ed7..fa7242c6 100644 --- a/lib/sendbird_chat_sdk.dart +++ b/lib/sendbird_chat_sdk.dart @@ -43,7 +43,6 @@ export 'src/public/main/handler/session_handler.dart'; export 'src/public/main/handler/user_event_handler.dart'; export 'src/public/main/model/channel/feed_channel_change_logs.dart'; export 'src/public/main/model/channel/group_channel_change_logs.dart'; -export 'src/public/main/model/channel/group_channel_filter.dart'; export 'src/public/main/model/channel/group_channel_unread_item_count.dart'; export 'src/public/main/model/channel/notification_category.dart'; export 'src/public/main/model/chat/do_not_disturb.dart'; diff --git a/lib/src/internal/main/chat/chat.dart b/lib/src/internal/main/chat/chat.dart index 32fd2980..48f70e09 100644 --- a/lib/src/internal/main/chat/chat.dart +++ b/lib/src/internal/main/chat/chat.dart @@ -58,7 +58,7 @@ part 'chat_notifications.dart'; part 'chat_push.dart'; part 'chat_user.dart'; -const sdkVersion = '4.1.1'; +const sdkVersion = '4.1.2'; // Internal implementation for main class. Do not directly access this class. class Chat with WidgetsBindingObserver { diff --git a/lib/src/internal/main/model/group_channel_filter.dart b/lib/src/internal/main/model/group_channel_filter.dart new file mode 100644 index 00000000..6b5cfe95 --- /dev/null +++ b/lib/src/internal/main/model/group_channel_filter.dart @@ -0,0 +1,106 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'package:json_annotation/json_annotation.dart'; +import 'package:sendbird_chat_sdk/sendbird_chat_sdk.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/utils/enum_utils.dart'; + +part 'group_channel_filter.g.dart'; + +// The GroupChannelFilter class for [GroupChannelListQuery] and [PublicGroupChannelListQuery]. +@JsonSerializable() +class GroupChannelFilter { + // Sets the member state filter. + @JsonKey(toJson: memberStateFilterEnumForQuery) + MyMemberStateFilter memberStateFilter = MyMemberStateFilter.all; + + // Sets to filter super channel. Default is `all`. + @JsonKey(toJson: groupChannelSuperFilterEnum) + SuperChannelFilter superMode = SuperChannelFilter.all; + + // Sets to filter public channel. Default is `all`. + PublicChannelFilter publicMode = PublicChannelFilter.all; + + // Sets to filter channels by custom type that starts with. + @JsonKey(name: 'custom_type_startswith') + String? customTypeStartsWith; + + // Sets the custom type filter. + List? customTypes; + + // Sets the filter with nickname. + // Query result will contains channels that any one of member contains given nickname. + String? membersNicknameContains; + + // Sets the filter with user IDs that query result will return + // if any one of user id matches with channel's members. + @JsonKey(includeFromJson: false, includeToJson: false) + List? membersIncludeIn; + + // Sets the filter with user IDs that query result will return + // only if channel's members are exactly matched with this property. + List? membersExactlyIn; + + // Sets a filter to return only channels that contains the + // specified group channel name. + String? nameContains; + + // Sets to filter channels by the unread messages. + // The default value is `all`. + UnreadChannelFilter unreadFilter = UnreadChannelFilter.all; + + // Sets a key for ordering by value in the metadata. + // This is valid when the `order` is `channelMetaDataValueAlphabetical` only. + @JsonKey(includeFromJson: false, includeToJson: false) + String? metadataOrderKey; + + // Sets to filter channels by the hidden state. + // The default value is `unhidden`. + HiddenChannelFilter hiddenMode = HiddenChannelFilter.unhidden; + + // Sets to filter channels by the membership filter. + // The default value is `all`. + @JsonKey(name: 'public_membership_mode') + MembershipFilter publicMembershipFilter = MembershipFilter.all; + + // Searches for group channels with metadata containing an item with the + // specified key. + @JsonKey(name: 'metadata_key') + String? metaDataKey; + + // Searches for group channels with metadata containing an item with the + // specified values. + @JsonKey(name: 'metadata_values') + List? metaDataValues; + + // Searches for group channels with metadata containing an item with the + // key specified by the metaDataKey and the values of that item start with + // the specified value. + @JsonKey(name: 'metadata_value_startswith') + String? metaDataValueStartsWithFilter; + + // Restricts the search scope to only retrieve group channels which have been created before the specified time, in milliseconds. + int? createdBefore; + + // Restricts the search scope to only retrieve group channels which have been created after the specified time, in milliseconds. + int? createdAfter; + + static GroupChannelFilter fromJson(Map json) { + return _$GroupChannelFilterFromJson(json); + } + + Map toJson() { + final json = _$GroupChannelFilterToJson(this); + if (json['metadata_key'] == null) { + json.remove('metadata_values'); + json.remove('metadata_value_startswith'); + } + return json; + } + + static int? toSec(int? ms) { + if (ms != null && ms.toString().length == 13) { + return ms ~/ 1000; + } + return ms; + } +} diff --git a/lib/src/public/main/model/channel/group_channel_filter.g.dart b/lib/src/internal/main/model/group_channel_filter.g.dart similarity index 93% rename from lib/src/public/main/model/channel/group_channel_filter.g.dart rename to lib/src/internal/main/model/group_channel_filter.g.dart index 23fd2e7c..81202db3 100644 --- a/lib/src/public/main/model/channel/group_channel_filter.g.dart +++ b/lib/src/internal/main/model/group_channel_filter.g.dart @@ -33,7 +33,9 @@ GroupChannelFilter _$GroupChannelFilterFromJson(Map json) => ?.map((e) => e as String) .toList() ..metaDataValueStartsWithFilter = - json['metadata_value_startswith'] as String?; + json['metadata_value_startswith'] as String? + ..createdBefore = json['created_before'] as int? + ..createdAfter = json['created_after'] as int?; Map _$GroupChannelFilterToJson(GroupChannelFilter instance) => { @@ -53,6 +55,8 @@ Map _$GroupChannelFilterToJson(GroupChannelFilter instance) => 'metadata_key': instance.metaDataKey, 'metadata_values': instance.metaDataValues, 'metadata_value_startswith': instance.metaDataValueStartsWithFilter, + 'created_before': instance.createdBefore, + 'created_after': instance.createdAfter, }; const _$MyMemberStateFilterEnumMap = { diff --git a/lib/src/internal/network/http/http_client/request/channel/group_channel/group_channel_list_request.dart b/lib/src/internal/network/http/http_client/request/channel/group_channel/group_channel_list_request.dart index 6bff8c20..abc6d930 100644 --- a/lib/src/internal/network/http/http_client/request/channel/group_channel/group_channel_list_request.dart +++ b/lib/src/internal/network/http/http_client/request/channel/group_channel/group_channel_list_request.dart @@ -10,7 +10,7 @@ import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/ import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/response/responses.dart'; import 'package:sendbird_chat_sdk/src/public/core/channel/group_channel/group_channel.dart'; import 'package:sendbird_chat_sdk/src/public/main/define/enums.dart'; -import 'package:sendbird_chat_sdk/src/public/main/model/channel/group_channel_filter.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/model/group_channel_filter.dart'; class GroupChannelListRequest extends ApiRequest { @override diff --git a/lib/src/internal/network/http/http_client/request/channel/group_channel/public/public_group_channel_list_request.dart b/lib/src/internal/network/http/http_client/request/channel/group_channel/public/public_group_channel_list_request.dart index a79fe679..88a62e4e 100644 --- a/lib/src/internal/network/http/http_client/request/channel/group_channel/public/public_group_channel_list_request.dart +++ b/lib/src/internal/network/http/http_client/request/channel/group_channel/public/public_group_channel_list_request.dart @@ -9,7 +9,7 @@ import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/ import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/response/responses.dart'; import 'package:sendbird_chat_sdk/src/public/core/channel/group_channel/group_channel.dart'; import 'package:sendbird_chat_sdk/src/public/main/define/enums.dart'; -import 'package:sendbird_chat_sdk/src/public/main/model/channel/group_channel_filter.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/model/group_channel_filter.dart'; class PublicGroupChannelListRequest extends ApiRequest { @override diff --git a/lib/src/public/core/channel/base_channel/base_channel.dart b/lib/src/public/core/channel/base_channel/base_channel.dart index 091d5170..7f129d3b 100644 --- a/lib/src/public/core/channel/base_channel/base_channel.dart +++ b/lib/src/public/core/channel/base_channel/base_channel.dart @@ -254,29 +254,44 @@ abstract class BaseChannel implements Cacheable { @override bool operator ==(other) { if (identical(other, this)) return true; + if (other is! BaseChannel) return false; + + bool result = true; + if (this is! FeedChannel && other is! FeedChannel) { + result = other.coverUrl == coverUrl && + other.data == data && + other.customType == customType && + other.isFrozen == isFrozen && + other.isEphemeral == isEphemeral; + } - return other is BaseChannel && - other.channelUrl == channelUrl && + return other.channelUrl == channelUrl && other.name == name && - other.coverUrl == coverUrl && other.createdAt == createdAt && - other.data == data && - other.customType == customType && - other.isFrozen == isFrozen && - other.isEphemeral == isEphemeral; + result; } @override - int get hashCode => Object.hash( + int get hashCode { + if (this is FeedChannel) { + return Object.hash( + channelUrl, + name, + createdAt, + ); + } else { + return Object.hash( channelUrl, name, - coverUrl, createdAt, + coverUrl, data, customType, isFrozen, isEphemeral, ); + } + } @override String get key => 'channel/$channelType$channelUrl'; @@ -288,14 +303,17 @@ abstract class BaseChannel implements Cacheable { void copyWith(dynamic other) { if (other is! BaseChannel) return; + if (this is! FeedChannel && other is! FeedChannel) { + coverUrl = other.coverUrl; + data = other.data; + customType = other.customType; + isFrozen = other.isFrozen; + isEphemeral = other.isEphemeral; + } + channelUrl = other.channelUrl; name = other.name; createdAt = other.createdAt; - _coverUrl = other._coverUrl; - _data = other._data; - _customType = other._customType; - _isFrozen = other._isFrozen; - _isEphemeral = other._isEphemeral; fromCache = other.fromCache; dirty = other.dirty; diff --git a/lib/src/public/core/channel/feed_channel/feed_channel.dart b/lib/src/public/core/channel/feed_channel/feed_channel.dart index 41b15fe1..d6ecd91b 100644 --- a/lib/src/public/core/channel/feed_channel/feed_channel.dart +++ b/lib/src/public/core/channel/feed_channel/feed_channel.dart @@ -21,6 +21,7 @@ import 'package:sendbird_chat_sdk/src/public/main/model/channel/notification_cat /// Represents a feed channel. /// @since 4.0.3 class FeedChannel extends BaseChannel { + static const _markAsClickedMessagesLimit = 30; static const _logImpressionMessagesLimit = 30; static const _logCustomMessagesLimit = 30; static const _logCustomTopicLengthLimit = 15; @@ -200,66 +201,88 @@ class FeedChannel extends BaseChannel { ); } - /// Sends mark as read to this channel. + /// Sends mark as read all to this channel. + /// If [messages] is not null, the [messages] will be marked as read to this channel. /// @since 4.1.0 - Future markAsRead() async { + Future markAsRead({List? messages}) async { sbLog.i(StackTrace.current); + List? messageIds; + if (messages != null) { + messageIds = []; + for (final message in messages) { + if (message.messageStatus == NotificationMessageStatus.sent) { + messageIds.add(message.notificationId); + } + } + if (messageIds.isEmpty) return; + } + final res = await chat.apiClient .send>(FeedChannelMarkAsReadRequest( chat, channelUrl: channelUrl, + messageIds: messageIds, )); - final ts = res['ts'] ?? 0; - chat.collectionManager.markAsReadForFeedChannel(channelUrl, null); + chat.collectionManager.markAsReadForFeedChannel(channelUrl, messageIds); - if (chat.currentUser != null) { - final status = ReadStatus( - userId: chat.currentUser!.userId, - timestamp: ts, - channelUrl: channelUrl, - channelType: channelType, - ); - status.saveToCache(chat); - } - groupChannel.myLastRead = ts; + if (messageIds == null) { + final ts = res['ts'] ?? 0; - if (groupChannel.unreadMessageCount > 0 || - groupChannel.unreadMentionCount > 0) { - groupChannel.clearUnreadCount(); - // chat.eventManager.notifyChannelChanged(this); // Refer to [_processChannelPropChanged] - } - } + if (chat.currentUser != null) { + final status = ReadStatus( + userId: chat.currentUser!.userId, + timestamp: ts, + channelUrl: channelUrl, + channelType: channelType, + ); + status.saveToCache(chat); + } + groupChannel.myLastRead = ts; - /// Sends mark as read to this channel by messages. - /// @since 4.1.0 - Future markAsReadBy(List messages) async { - sbLog.i(StackTrace.current); + if (groupChannel.unreadMessageCount > 0 || + groupChannel.unreadMentionCount > 0) { + groupChannel.clearUnreadCount(); + // chat.eventManager.notifyChannelChanged(this); // Refer to [_processChannelPropChanged] + } + } else { + final unreadMessageCount = res['unread_message_count'] ?? 0; - final List messageIds = []; - for (final message in messages) { - if (message.messageStatus == NotificationMessageStatus.sent) { - messageIds.add(message.notificationId); + if (unreadMessageCount != null && + unreadMessageCount != groupChannel.unreadMessageCount) { + groupChannel.unreadMessageCount = unreadMessageCount; + // chat.eventManager.notifyChannelChanged(this); // Refer to [_processChannelPropChanged] } } - if (messageIds.isEmpty) return; - - final res = await chat.apiClient - .send>(FeedChannelMarkAsReadRequest( - chat, - channelUrl: channelUrl, - messageIds: messageIds, - )); - final unreadMessageCount = res['unread_message_count']; + } - chat.collectionManager.markAsReadForFeedChannel(channelUrl, messageIds); + /// markAsClicked + /// @since 4.1.2 + Future markAsClicked(List messages) async { + if (messages.isNotEmpty && messages.length <= _markAsClickedMessagesLimit) { + bool result = true; + for (final message in messages) { + final Map data = { + 'action': 'clicked', + 'template_key': message.notificationData?.templateKey ?? '', + 'channel_url': message.channelUrl, + 'tags': message.notificationData?.tags ?? [], + 'message_id': message.notificationId, + 'source': 'notification', + 'message_ts': message.createdAt, + }; - if (unreadMessageCount != null && - unreadMessageCount != groupChannel.unreadMessageCount) { - groupChannel.unreadMessageCount = unreadMessageCount; - // chat.eventManager.notifyChannelChanged(this); // Refer to [_processChannelPropChanged] + if (!await SendbirdStatistics.appendStat( + type: 'noti:stats', + data: data, + )) { + result = false; + } + } + return result; } + return false; } /// logImpression diff --git a/lib/src/public/main/model/channel/group_channel_filter.dart b/lib/src/public/main/model/channel/group_channel_filter.dart deleted file mode 100644 index ac47cfbb..00000000 --- a/lib/src/public/main/model/channel/group_channel_filter.dart +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) 2023 Sendbird, Inc. All rights reserved. - -import 'package:json_annotation/json_annotation.dart'; -import 'package:sendbird_chat_sdk/sendbird_chat_sdk.dart'; -import 'package:sendbird_chat_sdk/src/internal/main/utils/enum_utils.dart'; - -part 'group_channel_filter.g.dart'; - -/// The GroupChannelFilter class for [GroupChannelListQuery] and [PublicGroupChannelListQuery]. -@JsonSerializable() -class GroupChannelFilter { - /// Sets the member state filter. - @JsonKey(toJson: memberStateFilterEnumForQuery) - MyMemberStateFilter memberStateFilter = MyMemberStateFilter.all; - - /// Sets to filter super channel. Default is `all`. - @JsonKey(toJson: groupChannelSuperFilterEnum) - SuperChannelFilter superMode = SuperChannelFilter.all; - - /// Sets to filter public channel. Default is `all`. - PublicChannelFilter publicMode = PublicChannelFilter.all; - - /// Sets to filter channels by custom type that starts with. - @JsonKey(name: 'custom_type_startswith') - String? customTypeStartsWith; - - /// Sets the custom type filter. - List? customTypes; - - /// Sets the filter with nickname. - /// Query result will contains channels that any one of member contains given nickname. - String? membersNicknameContains; - - /// Sets the filter with user IDs that query result will return - /// if any one of user id matches with channel's members. - @JsonKey(includeFromJson: false, includeToJson: false) - List? membersIncludeIn; - - /// Sets the filter with user IDs that query result will return - /// only if channel's members are exactly matched with this property. - List? membersExactlyIn; - - /// Sets a filter to return only channels that contains the - /// specified group channel name. - String? nameContains; - - /// Sets to filter channels by the unread messages. - /// The default value is `all`. - UnreadChannelFilter unreadFilter = UnreadChannelFilter.all; - - /// Sets a key for ordering by value in the metadata. - /// This is valid when the `order` is `channelMetaDataValueAlphabetical` only. - @JsonKey(includeFromJson: false, includeToJson: false) - String? metadataOrderKey; - - /// Sets to filter channels by the hidden state. - /// The default value is `unhidden`. - HiddenChannelFilter hiddenMode = HiddenChannelFilter.unhidden; - - /// Sets to filter channels by the membership filter. - /// The default value is `all`. - @JsonKey(name: 'public_membership_mode') - MembershipFilter publicMembershipFilter = MembershipFilter.all; - - /// Searches for group channels with metadata containing an item with the - /// specified key. - @JsonKey(name: 'metadata_key') - String? metaDataKey; - - /// Searches for group channels with metadata containing an item with the - /// specified values. - @JsonKey(name: 'metadata_values') - List? metaDataValues; - - /// Searches for group channels with metadata containing an item with the - /// key specified by the metaDataKey and the values of that item start with - /// the specified value. - @JsonKey(name: 'metadata_value_startswith') - String? metaDataValueStartsWithFilter; - - static GroupChannelFilter fromJson(Map json) { - return _$GroupChannelFilterFromJson(json); - } - - Map toJson() { - final json = _$GroupChannelFilterToJson(this); - if (json['metadata_key'] == null) { - json.remove('metadata_values'); - json.remove('metadata_value_startswith'); - } - return json; - } -} diff --git a/lib/src/public/main/model/reaction/reaction_event.dart b/lib/src/public/main/model/reaction/reaction_event.dart index 2a9ced06..377dfebd 100644 --- a/lib/src/public/main/model/reaction/reaction_event.dart +++ b/lib/src/public/main/model/reaction/reaction_event.dart @@ -21,20 +21,23 @@ class ReactionEvent { final String channelUrl; // Check /// The message ID which contains the [Reaction] of this event. - @JsonKey(name: 'msg_id') + @JsonKey(name: 'msg_id', defaultValue: 0) int messageId; /// The key of the [Reaction] this event belongs to. - @JsonKey(name: 'reaction') + @JsonKey(name: 'reaction', defaultValue: '') final String key; - /// The user ID of the [User] who have created this reaction event.. + /// The user ID of the [User] who have created this reaction event. + @JsonKey(defaultValue: '') final String userId; /// Refer to [ReactionEventAction]. + @JsonKey(defaultValue: ReactionEventAction.delete) final ReactionEventAction operation; /// The updated timestamp of the reaction event in milliseconds. + @JsonKey(defaultValue: 0) final int updatedAt; ReactionEvent({ diff --git a/lib/src/public/main/model/reaction/reaction_event.g.dart b/lib/src/public/main/model/reaction/reaction_event.g.dart index 25758453..66280478 100644 --- a/lib/src/public/main/model/reaction/reaction_event.g.dart +++ b/lib/src/public/main/model/reaction/reaction_event.g.dart @@ -13,11 +13,13 @@ ReactionEvent _$ReactionEventFromJson(Map json) => unknownValue: ChannelType.group) ?? ChannelType.group, channelUrl: json['channel_url'] as String? ?? '', - messageId: json['msg_id'] as int, - key: json['reaction'] as String, - userId: json['user_id'] as String, - operation: $enumDecode(_$ReactionEventActionEnumMap, json['operation']), - updatedAt: json['updated_at'] as int, + messageId: json['msg_id'] as int? ?? 0, + key: json['reaction'] as String? ?? '', + userId: json['user_id'] as String? ?? '', + operation: $enumDecodeNullable( + _$ReactionEventActionEnumMap, json['operation']) ?? + ReactionEventAction.delete, + updatedAt: json['updated_at'] as int? ?? 0, ); const _$ChannelTypeEnumMap = { diff --git a/lib/src/public/main/query/channel/group_channel_list_query.dart b/lib/src/public/main/query/channel/group_channel_list_query.dart index 717053c9..7775a1e5 100644 --- a/lib/src/public/main/query/channel/group_channel_list_query.dart +++ b/lib/src/public/main/query/channel/group_channel_list_query.dart @@ -4,6 +4,7 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; import 'package:sendbird_chat_sdk/src/internal/main/extensions/extensions.dart'; import 'package:sendbird_chat_sdk/src/internal/main/logger/sendbird_logger.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/model/group_channel_filter.dart'; import 'package:sendbird_chat_sdk/src/internal/main/utils/enum_utils.dart'; import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/channel/group_channel/group_channel_list_request.dart'; import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/response/responses.dart'; @@ -12,7 +13,6 @@ import 'package:sendbird_chat_sdk/src/public/core/user/user.dart'; import 'package:sendbird_chat_sdk/src/public/main/chat/sendbird_chat.dart'; import 'package:sendbird_chat_sdk/src/public/main/define/enums.dart'; import 'package:sendbird_chat_sdk/src/public/main/define/exceptions.dart'; -import 'package:sendbird_chat_sdk/src/public/main/model/channel/group_channel_filter.dart'; import 'package:sendbird_chat_sdk/src/public/main/query/base_query.dart'; /// A class representing query to retrieve [GroupChannel] list for the current [User]. @@ -112,6 +112,14 @@ class GroupChannelListQuery extends BaseQuery { /// @since 4.0.3 bool includeChatNotification = false; + /// Restricts the search scope to only retrieve group channels which have been created before the specified time, in milliseconds. + /// @since 4.1.2 + int? createdBefore; + + /// Restricts the search scope to only retrieve group channels which have been created after the specified time, in milliseconds. + /// @since 4.1.2 + int? createdAfter; + GroupChannelListQuery({ Chat? chat, }) : super(chat: chat ?? SendbirdChat().chat); @@ -221,7 +229,9 @@ class GroupChannelListQuery extends BaseQuery { ..hiddenMode = hiddenChannelFilter ..metaDataKey = metaDataKey ..metaDataValues = metaDataValues - ..metaDataValueStartsWithFilter = metaDataValueStartsWith; + ..metaDataValueStartsWithFilter = metaDataValueStartsWith + ..createdBefore = GroupChannelFilter.toSec(createdBefore) + ..createdAfter = GroupChannelFilter.toSec(createdAfter); final options = [ if (includeEmpty) ChannelListQueryIncludeOption.includeEmpty, diff --git a/lib/src/public/main/query/channel/public_group_channel_list_query.dart b/lib/src/public/main/query/channel/public_group_channel_list_query.dart index 29f9b6ed..16e4f990 100644 --- a/lib/src/public/main/query/channel/public_group_channel_list_query.dart +++ b/lib/src/public/main/query/channel/public_group_channel_list_query.dart @@ -3,13 +3,13 @@ import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; import 'package:sendbird_chat_sdk/src/internal/main/extensions/extensions.dart'; import 'package:sendbird_chat_sdk/src/internal/main/logger/sendbird_logger.dart'; +import 'package:sendbird_chat_sdk/src/internal/main/model/group_channel_filter.dart'; import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/channel/group_channel/public/public_group_channel_list_request.dart'; import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/response/responses.dart'; import 'package:sendbird_chat_sdk/src/public/core/channel/group_channel/group_channel.dart'; import 'package:sendbird_chat_sdk/src/public/main/chat/sendbird_chat.dart'; import 'package:sendbird_chat_sdk/src/public/main/define/enums.dart'; import 'package:sendbird_chat_sdk/src/public/main/define/exceptions.dart'; -import 'package:sendbird_chat_sdk/src/public/main/model/channel/group_channel_filter.dart'; import 'package:sendbird_chat_sdk/src/public/main/query/base_query.dart'; /// A class representing query to retrieve [GroupChannel] list for the current `User`. @@ -67,6 +67,14 @@ class PublicGroupChannelListQuery extends BaseQuery { /// default value is `true` bool includeMetaData = true; + /// Restricts the search scope to only retrieve group channels which have been created before the specified time, in milliseconds. + /// @since 4.1.2 + int? createdBefore; + + /// Restricts the search scope to only retrieve group channels which have been created after the specified time, in milliseconds. + /// @since 4.1.2 + int? createdAfter; + PublicGroupChannelListQuery({ Chat? chat, }) : super(chat: chat ?? SendbirdChat().chat); @@ -118,7 +126,9 @@ class PublicGroupChannelListQuery extends BaseQuery { ..metaDataKey = metaDataKey ..metaDataValues = metaDataValues ..metaDataValueStartsWithFilter = metaDataValueStartsWith - ..publicMode = PublicChannelFilter.public; + ..publicMode = PublicChannelFilter.public + ..createdBefore = GroupChannelFilter.toSec(createdBefore) + ..createdAfter = GroupChannelFilter.toSec(createdAfter); final res = await chat.apiClient.send>( diff --git a/pubspec.yaml b/pubspec.yaml index 32c8ac87..7ce24a84 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: sendbird_chat_sdk description: With Sendbird Chat for Flutter, you can easily build an in-app chat with all the essential messaging features. -version: 4.1.1 +version: 4.1.2 homepage: https://sendbird.com repository: https://github.com/sendbird/sendbird-chat-sdk-flutter documentation: https://sendbird.com/docs/chat/sdk/v4/flutter/getting-started/send-first-message