Skip to content

Commit

Permalink
Merge pull request #86 from sendbird/v4.1.0
Browse files Browse the repository at this point in the history
Add 4.1.0.
  • Loading branch information
sf-tyler-jeong authored Nov 3, 2023
2 parents 965905b + 2f12aa8 commit 080a549
Show file tree
Hide file tree
Showing 83 changed files with 1,800 additions and 731 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
## v4.1.0 (Nov 3, 2023)

### Features

#### NotificationMessage
- Added `NotificationMessage` with `notificationId`, `messageStatus` and `notificationData`
- Added `markAsReadBy()`, `logImpression()` and `logCustom()` in `FeedChannel`
- Replaced `BaseMessage? lastMessage` with `NotificationMessage? lastMessage` in `FeedChannel`
- Replaced `List<BaseMessage> messageList` with `List<NotificationMessage> messageList` in `NotificationCollection`
- Modified `onMessagesAdded()`, `onMessagesUpdated()` and `onMessagesDeleted()` in `NotificationCollectionHandler`
- Modified `onMessageReceived()` and `onChannelChanged()` in `FeedChannelHandler`

### Deprecated Methods
- Removed `onTotalUnreadMessageCountUpdated()` in `UserEventHandler`

### Improvements
- Improved stability

## v4.0.13 (Sep 27, 2023)

### Features
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Before installing Sendbird Chat SDK, you need to create a Sendbird application o

```yaml
dependencies:
sendbird_chat_sdk: ^4.0.13
sendbird_chat_sdk: ^4.1.0
```
- Run `flutter pub get` command in your project directory.
Expand Down
2 changes: 2 additions & 0 deletions lib/sendbird_chat_sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export 'src/public/core/channel/open_channel/open_channel.dart';
export 'src/public/core/message/admin_message.dart';
export 'src/public/core/message/base_message.dart';
export 'src/public/core/message/file_message.dart';
export 'src/public/core/message/notification_message.dart';
export 'src/public/core/message/root_message.dart';
export 'src/public/core/message/user_message.dart';
export 'src/public/core/user/member.dart';
export 'src/public/core/user/restricted_user.dart';
Expand Down
10 changes: 6 additions & 4 deletions lib/src/internal/main/chat/chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import 'package:sendbird_chat_sdk/src/internal/main/utils/async/async_task.dart'
import 'package:sendbird_chat_sdk/src/internal/network/http/api_client.dart';
import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/channel/feed_channel/feed_channel_change_logs_request.dart';
import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/channel/group_channel/group_channel_change_logs_request.dart';
import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/channel/group_channel/group_channel_delivery_request.dart';
import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/channel/group_channel/group_channel_read_request.dart';
import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/channel/group_channel/group_channel_mark_as_delivered_request.dart';
import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/channel/group_channel/group_channel_mark_as_read_all_request.dart';
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';
import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/channel/invitation/channel_invitation_preference_request.dart';
import 'package:sendbird_chat_sdk/src/internal/network/http/http_client/request/main/emoji/emoji_category_request.dart';
Expand Down Expand Up @@ -58,7 +58,7 @@ part 'chat_notifications.dart';
part 'chat_push.dart';
part 'chat_user.dart';

const sdkVersion = '4.0.13';
const sdkVersion = '4.1.0';

// Internal implementation for main class. Do not directly access this class.
class Chat with WidgetsBindingObserver {
Expand Down Expand Up @@ -87,6 +87,7 @@ class Chat with WidgetsBindingObserver {

bool? _isObserverRegistered;
ConnectivityResult _connectivityResult = ConnectivityResult.none;
int lastMarkAsReadTimestamp;

// This allows a value of type T or T? to be treated as a value of type T?.
// We use this so that APIs that have become non-nullable can still be used
Expand All @@ -110,7 +111,8 @@ class Chat with WidgetsBindingObserver {
Chat({
required String appId,
required SendbirdChatOptions options,
}) : chatId = globalChatId++ {
}) : chatId = globalChatId++,
lastMarkAsReadTimestamp = 0 {
chatContext = ChatContext(appId: appId, options: options);
channelCache = ChannelCache();
connectionManager = ConnectionManager(chat: this); // WebSocketClient
Expand Down
24 changes: 19 additions & 5 deletions lib/src/internal/main/chat/chat_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,29 @@ extension ChatChannel on Chat {

Future<void> markAsReadAll() async {
sbLog.i(StackTrace.current);
await apiClient.send(
GroupChannelMarkAsReadRequest(this, userId: chatContext.currentUserId));

final now = DateTime.now().millisecondsSinceEpoch;
if (now - lastMarkAsReadTimestamp <= 1000) {
throw MarkAsReadRateLimitExceededException();
}
lastMarkAsReadTimestamp = now;

await apiClient.send(GroupChannelMarkAsReadAllRequest(this,
userId: chatContext.currentUserId));
}

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

if (channelUrls.isEmpty) throw InvalidParameterException();
await apiClient.send(GroupChannelMarkAsReadRequest(

final now = DateTime.now().millisecondsSinceEpoch;
if (now - lastMarkAsReadTimestamp <= 1000) {
throw MarkAsReadRateLimitExceededException();
}
lastMarkAsReadTimestamp = now;

await apiClient.send(GroupChannelMarkAsReadAllRequest(
this,
channelUrls: channelUrls,
userId: chatContext.currentUserId,
Expand Down Expand Up @@ -141,8 +155,8 @@ extension ChatChannel on Chat {
}

int get subscribedCustomTypeTotalUnreadMessageCount {
final result =
chatContext.unreadMessageCountInfo.customTypes.values.reduce((a, b) => a + b);
final result = chatContext.unreadMessageCountInfo.customTypes.values
.reduce((a, b) => a + b);
sbLog.i(StackTrace.current, 'return: $result');
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/internal/main/chat/chat_event_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
part of 'chat.dart';

extension ChatEventHandler on Chat {
void addChannelHandler(String identifier, BaseChannelHandler handler) {
void addChannelHandler(String identifier, RootChannelHandler handler) {
sbLog.i(StackTrace.current, 'identifier: $identifier');
eventManager.addChannelHandler(identifier, handler);
}
Expand Down
Loading

0 comments on commit 080a549

Please sign in to comment.