Skip to content

Commit

Permalink
Add 4.2.27.
Browse files Browse the repository at this point in the history
  • Loading branch information
sf-tyler-jeong committed Nov 6, 2024
1 parent 63a0786 commit 645d016
Show file tree
Hide file tree
Showing 53 changed files with 221 additions and 131 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## v4.2.27 (Nov 6, 2024)

### Features
- Applied the message threading policy for last message and unread message count in `GroupChannel`

### Improvements
- Fixed a bug where update events are not called for messages with OGTags
- Fixed the reconnection events to be called in pairs

## v4.2.26 (Oct 28, 2024)

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

```yaml
dependencies:
sendbird_chat_sdk: ^4.2.26
sendbird_chat_sdk: ^4.2.27
```
- Run `flutter pub get` command in your project directory.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/internal/main/chat/chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ part 'chat_notifications.dart';
part 'chat_push.dart';
part 'chat_user.dart';

const sdkVersion = '4.2.26';
const sdkVersion = '4.2.27';

// Internal implementation for main class. Do not directly access this class.
class Chat with WidgetsBindingObserver {
Expand Down
2 changes: 2 additions & 0 deletions lib/src/internal/main/chat_manager/command_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ class CommandManager {

groupChannel.updateMember(event.sender);

// Last message
if (channel is GroupChannel && message is BaseMessage) {
if (groupChannel.shouldUpdateLastMessage(message, message.sender)) {
shouldCallChannelChanged = true;
Expand All @@ -459,6 +460,7 @@ class CommandManager {
}
}

// Unread message count
if (groupChannel.fromCache && groupChannel.updateUnreadCount(message)) {
shouldCallChannelChanged = true;
}
Expand Down
20 changes: 12 additions & 8 deletions lib/src/internal/main/chat_manager/connection_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,6 @@ class ConnectionManager {
if (isReconnecting()) {
reconnectTimer?.cancel();
reconnectTimer = null;
if (clear) {
chat.eventManager.notifyReconnectFailed();
}
}

final isClosedSuccessfully = await webSocketClient.close();
Expand Down Expand Up @@ -298,6 +295,9 @@ class ConnectionManager {
if (fromEnterBackground && !chat.isBackground && !isClosedSuccessfully) {
chat.connectionManager.reconnect(reset: true); // Check
} else {
if (isReconnecting()) {
chat.eventManager.notifyReconnectFailed();
}
changeState(DisconnectedState(chat: chat));

if (clear && disconnectedUserId.isNotEmpty) {
Expand All @@ -309,11 +309,13 @@ class ConnectionManager {
Future<bool> doReconnect({bool reset = false}) async {
sbLog.i(StackTrace.current, 'reset: $reset');

bool doNotCallReconnectStartedEvent = false;
if (isReconnecting() && reset) {
doNotCallReconnectStartedEvent = true;
}

if (chat.chatContext.currentUser == null ||
chat.chatContext.sessionKey == null) {
if (isReconnecting()) {
chat.eventManager.notifyReconnectFailed();
}
changeState(DisconnectedState(chat: chat));
return false;
}
Expand Down Expand Up @@ -348,8 +350,10 @@ class ConnectionManager {
);

if (chat.chatContext.reconnectTask?.retryCount == 1) {
await chat.eventDispatcher.onReconnecting();
chat.eventManager.notifyReconnectStarted();
if (!doNotCallReconnectStartedEvent) {
await chat.eventDispatcher.onReconnecting();
chat.eventManager.notifyReconnectStarted();
}
}

// ===== Reconnect =====
Expand Down
50 changes: 50 additions & 0 deletions lib/src/internal/main/extensions/group_channel_extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ part of 'package:sendbird_chat_sdk/src/public/core/channel/group_channel/group_c

extension GroupChannelExtensions on GroupChannel {
bool shouldUpdateLastMessage(BaseMessage message, Sender? sender) {
if (_shouldUpdateLastMessageByThreadingPolicy(message) == false) {
return false;
}

final lm = lastMessage;
if (!message.isSilent ||
sender?.isCurrentUser == true ||
Expand All @@ -22,6 +26,10 @@ extension GroupChannelExtensions on GroupChannel {
}

bool updateUnreadCount(RootMessage message) {
if (_shouldUpdateUnreadMessageCountByThreadingPolicy(message) == false) {
return false;
}

final currentUser = chat.chatContext.currentUser;

if (message is BaseMessage) {
Expand Down Expand Up @@ -165,4 +173,46 @@ extension GroupChannelExtensions on GroupChannel {
.toList()
.length;
}

bool _shouldUpdateLastMessageByThreadingPolicy(RootMessage message) {
return _shouldUpdateByThreadingPolicy(
message: message,
threadingPolicy: chat.chatContext.appInfo?.lastMsgThreadingPolicy,
);
}

bool _shouldUpdateUnreadMessageCountByThreadingPolicy(RootMessage message) {
return _shouldUpdateByThreadingPolicy(
message: message,
threadingPolicy: chat.chatContext.appInfo?.unreadCntThreadingPolicy,
);
}

bool _shouldUpdateByThreadingPolicy({
required RootMessage message,
required int? threadingPolicy,
}) {
bool result = true;
bool isReplyMessage = message is BaseMessage &&
message.parentMessageId != null &&
message.parentMessageId! > 0;

if (isReplyMessage && threadingPolicy != null) {
switch (threadingPolicy) {
case 0: // NONE
break;
case 1: // INCLUDE_REPLY
break;
case 2: // EXCLUDE_REPLY
result = false;
break;
case 3: // INCLUDE_REPLY_TO_CHANNEL
if (message.isReplyToChannel == false) {
result = false;
}
break;
}
}
return result;
}
}
2 changes: 1 addition & 1 deletion lib/src/internal/main/model/delivery_status.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/src/internal/main/model/group_channel_filter.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/src/internal/main/model/read_status.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/src/internal/main/model/reconnect_configuration.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions lib/src/internal/main/model/unread_message_count_info.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/src/internal/network/websocket/command/command.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions lib/src/internal/network/websocket/event/channel_event.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions lib/src/internal/network/websocket/event/login_event.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/src/internal/network/websocket/event/mcnt_event.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/src/internal/network/websocket/event/user_event.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 12 additions & 11 deletions lib/src/public/core/channel/group_channel/group_channel.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/src/public/core/channel/open_channel/open_channel.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 645d016

Please sign in to comment.