Skip to content

Commit 080a549

Browse files
Merge pull request #86 from sendbird/v4.1.0
Add 4.1.0.
2 parents 965905b + 2f12aa8 commit 080a549

File tree

83 files changed

+1800
-731
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1800
-731
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
## v4.1.0 (Nov 3, 2023)
2+
3+
### Features
4+
5+
#### NotificationMessage
6+
- Added `NotificationMessage` with `notificationId`, `messageStatus` and `notificationData`
7+
- Added `markAsReadBy()`, `logImpression()` and `logCustom()` in `FeedChannel`
8+
- Replaced `BaseMessage? lastMessage` with `NotificationMessage? lastMessage` in `FeedChannel`
9+
- Replaced `List<BaseMessage> messageList` with `List<NotificationMessage> messageList` in `NotificationCollection`
10+
- Modified `onMessagesAdded()`, `onMessagesUpdated()` and `onMessagesDeleted()` in `NotificationCollectionHandler`
11+
- Modified `onMessageReceived()` and `onChannelChanged()` in `FeedChannelHandler`
12+
13+
### Deprecated Methods
14+
- Removed `onTotalUnreadMessageCountUpdated()` in `UserEventHandler`
15+
16+
### Improvements
17+
- Improved stability
18+
119
## v4.0.13 (Sep 27, 2023)
220

321
### Features

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Before installing Sendbird Chat SDK, you need to create a Sendbird application o
4848

4949
```yaml
5050
dependencies:
51-
sendbird_chat_sdk: ^4.0.13
51+
sendbird_chat_sdk: ^4.1.0
5252
```
5353
5454
- Run `flutter pub get` command in your project directory.

lib/sendbird_chat_sdk.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export 'src/public/core/channel/open_channel/open_channel.dart';
1010
export 'src/public/core/message/admin_message.dart';
1111
export 'src/public/core/message/base_message.dart';
1212
export 'src/public/core/message/file_message.dart';
13+
export 'src/public/core/message/notification_message.dart';
14+
export 'src/public/core/message/root_message.dart';
1315
export 'src/public/core/message/user_message.dart';
1416
export 'src/public/core/user/member.dart';
1517
export 'src/public/core/user/restricted_user.dart';

lib/src/internal/main/chat/chat.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import 'package:sendbird_chat_sdk/src/internal/main/utils/async/async_task.dart'
2222
import 'package:sendbird_chat_sdk/src/internal/network/http/api_client.dart';
2323
import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/channel/feed_channel/feed_channel_change_logs_request.dart';
2424
import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/channel/group_channel/group_channel_change_logs_request.dart';
25-
import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/channel/group_channel/group_channel_delivery_request.dart';
26-
import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/channel/group_channel/group_channel_read_request.dart';
25+
import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/channel/group_channel/group_channel_mark_as_delivered_request.dart';
26+
import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/channel/group_channel/group_channel_mark_as_read_all_request.dart';
2727
import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/channel/group_channel/scheduled_message/group_channel_scheduled_message_total_count_request.dart';
2828
import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/channel/invitation/channel_invitation_preference_request.dart';
2929
import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/main/emoji/emoji_category_request.dart';
@@ -58,7 +58,7 @@ part 'chat_notifications.dart';
5858
part 'chat_push.dart';
5959
part 'chat_user.dart';
6060

61-
const sdkVersion = '4.0.13';
61+
const sdkVersion = '4.1.0';
6262

6363
// Internal implementation for main class. Do not directly access this class.
6464
class Chat with WidgetsBindingObserver {
@@ -87,6 +87,7 @@ class Chat with WidgetsBindingObserver {
8787

8888
bool? _isObserverRegistered;
8989
ConnectivityResult _connectivityResult = ConnectivityResult.none;
90+
int lastMarkAsReadTimestamp;
9091

9192
// This allows a value of type T or T? to be treated as a value of type T?.
9293
// We use this so that APIs that have become non-nullable can still be used
@@ -110,7 +111,8 @@ class Chat with WidgetsBindingObserver {
110111
Chat({
111112
required String appId,
112113
required SendbirdChatOptions options,
113-
}) : chatId = globalChatId++ {
114+
}) : chatId = globalChatId++,
115+
lastMarkAsReadTimestamp = 0 {
114116
chatContext = ChatContext(appId: appId, options: options);
115117
channelCache = ChannelCache();
116118
connectionManager = ConnectionManager(chat: this); // WebSocketClient

lib/src/internal/main/chat/chat_channel.dart

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,29 @@ extension ChatChannel on Chat {
5151

5252
Future<void> markAsReadAll() async {
5353
sbLog.i(StackTrace.current);
54-
await apiClient.send(
55-
GroupChannelMarkAsReadRequest(this, userId: chatContext.currentUserId));
54+
55+
final now = DateTime.now().millisecondsSinceEpoch;
56+
if (now - lastMarkAsReadTimestamp <= 1000) {
57+
throw MarkAsReadRateLimitExceededException();
58+
}
59+
lastMarkAsReadTimestamp = now;
60+
61+
await apiClient.send(GroupChannelMarkAsReadAllRequest(this,
62+
userId: chatContext.currentUserId));
5663
}
5764

5865
Future<void> markAsRead({required List<String> channelUrls}) async {
5966
sbLog.i(StackTrace.current, 'channelUrls: $channelUrls');
6067

6168
if (channelUrls.isEmpty) throw InvalidParameterException();
62-
await apiClient.send(GroupChannelMarkAsReadRequest(
69+
70+
final now = DateTime.now().millisecondsSinceEpoch;
71+
if (now - lastMarkAsReadTimestamp <= 1000) {
72+
throw MarkAsReadRateLimitExceededException();
73+
}
74+
lastMarkAsReadTimestamp = now;
75+
76+
await apiClient.send(GroupChannelMarkAsReadAllRequest(
6377
this,
6478
channelUrls: channelUrls,
6579
userId: chatContext.currentUserId,
@@ -141,8 +155,8 @@ extension ChatChannel on Chat {
141155
}
142156

143157
int get subscribedCustomTypeTotalUnreadMessageCount {
144-
final result =
145-
chatContext.unreadMessageCountInfo.customTypes.values.reduce((a, b) => a + b);
158+
final result = chatContext.unreadMessageCountInfo.customTypes.values
159+
.reduce((a, b) => a + b);
146160
sbLog.i(StackTrace.current, 'return: $result');
147161
return result;
148162
}

lib/src/internal/main/chat/chat_event_handler.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
part of 'chat.dart';
44

55
extension ChatEventHandler on Chat {
6-
void addChannelHandler(String identifier, BaseChannelHandler handler) {
6+
void addChannelHandler(String identifier, RootChannelHandler handler) {
77
sbLog.i(StackTrace.current, 'identifier: $identifier');
88
eventManager.addChannelHandler(identifier, handler);
99
}

0 commit comments

Comments
 (0)