Skip to content

Commit c089a06

Browse files
Merge pull request #115 from sendbird/v4.2.19
Add 4.2.19.
2 parents c959466 + f658732 commit c089a06

File tree

9 files changed

+59
-34
lines changed

9 files changed

+59
-34
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## v4.2.19 (Jul 4, 2024)
2+
3+
### Improvements
4+
- Fixed a bug that channels are not added when `includeEmpty` is `false` in `GroupChannelCollection`
5+
- Fixed a bug regarding a channel event when leaving a `GroupChannel`
6+
- Fixed a bug regarding the filtering on multi `GroupChannelCollection`s
7+
18
## v4.2.18 (Jun 26, 2024)
29

310
### Improvements

README.md

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

5151
```yaml
5252
dependencies:
53-
sendbird_chat_sdk: ^4.2.18
53+
sendbird_chat_sdk: ^4.2.19
5454
```
5555
5656
- Run `flutter pub get` command in your project directory.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ part 'chat_notifications.dart';
6262
part 'chat_push.dart';
6363
part 'chat_user.dart';
6464

65-
const sdkVersion = '4.2.18';
65+
const sdkVersion = '4.2.19';
6666

6767
// Internal implementation for main class. Do not directly access this class.
6868
class Chat with WidgetsBindingObserver {

lib/src/internal/main/chat_manager/collection_manager/collection_manager.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,12 +454,10 @@ class InternalGroupChannelHandlerForCollectionManager
454454
}
455455
}
456456

457-
// (includeEmpty == false)
458457
if (channel is GroupChannel) {
459458
_collectionManager.sendEventsToGroupChannelCollectionList(
460459
eventSource: CollectionEventSource.eventMessageReceived,
461460
addedChannels: [channel],
462-
doNotUpsertAddedChannels: true,
463461
);
464462
}
465463
}

lib/src/internal/main/chat_manager/collection_manager/group_channel_collection_manager.dart

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ extension GroupChannelCollectionManager on CollectionManager {
117117
List<GroupChannel>? addedChannels,
118118
List<GroupChannel>? updatedChannels,
119119
List<String>? deletedChannelUrls,
120-
bool doNotUpsertAddedChannels = false, // (includeEmpty == false)
121120
}) async {
122121
sbLog.d(StackTrace.current, eventSource.toString());
123122

@@ -126,8 +125,14 @@ extension GroupChannelCollectionManager on CollectionManager {
126125
if (deletedChannelUrls != null) {
127126
await _chat.dbManager.deleteGroupChannels(deletedChannelUrls);
128127
}
129-
if (addedChannels != null && !doNotUpsertAddedChannels) {
130-
await _chat.dbManager.upsertGroupChannels(addedChannels);
128+
if (addedChannels != null) {
129+
if (eventSource == CollectionEventSource.channelLoadMore ||
130+
eventSource == CollectionEventSource.channelCacheLoadMore ||
131+
eventSource == CollectionEventSource.channelChangeLogs) {
132+
// Do upsertGroupChannels() in sendEventsToGroupChannelCollection().
133+
} else {
134+
await _chat.dbManager.upsertGroupChannels(addedChannels);
135+
}
131136
}
132137
if (updatedChannels != null) {
133138
await _chat.dbManager.upsertGroupChannels(updatedChannels);
@@ -173,18 +178,28 @@ extension GroupChannelCollectionManager on CollectionManager {
173178

174179
//+ [DBManager]
175180
if (_chat.dbManager.isEnabled()) {
176-
if (eventSource == CollectionEventSource.channelLoadMore ||
177-
eventSource == CollectionEventSource.channelCacheLoadMore) {
178-
if (deletedChannelUrls != null) {
179-
await _chat.dbManager.deleteGroupChannels(deletedChannelUrls);
180-
}
181-
if (addedChannels != null) {
181+
if (deletedChannelUrls != null) {
182+
await _chat.dbManager.deleteGroupChannels(deletedChannelUrls);
183+
}
184+
if (addedChannels != null) {
185+
if (eventSource == CollectionEventSource.channelLoadMore ||
186+
eventSource == CollectionEventSource.channelCacheLoadMore ||
187+
eventSource == CollectionEventSource.channelChangeLogs) {
188+
List<GroupChannel> unavailableChannels = [];
189+
for (final channel in addedChannels) {
190+
if (!await channelCollection.canAddChannel(eventSource, channel)) {
191+
unavailableChannels.add(channel);
192+
}
193+
}
194+
for (final channel in unavailableChannels) {
195+
addedChannels.remove(channel);
196+
}
182197
await _chat.dbManager.upsertGroupChannels(addedChannels);
183198
}
184-
if (updatedChannels != null) {
185-
// Not used
186-
await _chat.dbManager.upsertGroupChannels(updatedChannels);
187-
}
199+
}
200+
if (updatedChannels != null) {
201+
// Not used
202+
await _chat.dbManager.upsertGroupChannels(updatedChannels);
188203
}
189204
}
190205
//- [DBManager]

lib/src/internal/main/chat_manager/collection_manager/message_collection_manager.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,10 @@ extension MessageCollectionManager on CollectionManager {
7373
);
7474
}
7575

76-
// (includeEmpty == false)
7776
if (channel is GroupChannel) {
7877
sendEventsToGroupChannelCollectionList(
7978
eventSource: CollectionEventSource.eventMessageSent,
8079
addedChannels: [channel],
81-
doNotUpsertAddedChannels: true,
8280
);
8381
}
8482
}

lib/src/internal/main/chat_manager/command_manager.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ class CommandManager {
10001000
}
10011001
}
10021002
_chat.eventManager.notifyUserLeft(groupChannel, member);
1003-
_chat.eventManager.notifyChannelMemberCountChanged([groupChannel]);
1003+
// _chat.eventManager.notifyChannelMemberCountChanged([groupChannel]); // Check
10041004
}
10051005
}
10061006
}

lib/src/public/main/collection/group_channel_collection/group_channel_collection.dart

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,17 @@ class GroupChannelCollection {
255255
return false;
256256
}
257257

258-
// (includeEmpty == false)
259258
if (_query.includeEmpty == false) {
260-
if (addedChannel.lastMessage == null) {
261-
return false;
262-
} else {
263-
if (eventSource == CollectionEventSource.eventMessageSent ||
264-
eventSource == CollectionEventSource.eventMessageReceived) {
265-
return true;
259+
if (checkToUpdateChannel == false) {
260+
if (eventSource == CollectionEventSource.channelCacheLoadMore ||
261+
eventSource == CollectionEventSource.channelLoadMore) {
262+
if (addedChannel.lastMessage == null) {
263+
return false;
264+
}
265+
} else if (eventSource == CollectionEventSource.eventMessageSent) {
266+
if (addedChannel.lastMessage == null) {
267+
return true; // Check
268+
}
266269
}
267270
}
268271
}
@@ -321,13 +324,17 @@ class GroupChannelCollection {
321324
}
322325
}
323326

324-
// if (eventSource == CollectionEventSource.channelChangeLogs) { // Check
325-
if (await _chat.dbManager.canAddChannel(
326-
query: _query, channelUrl: addedChannel.channelUrl) ==
327-
false) {
328-
return false;
327+
if (checkToUpdateChannel == false) {
328+
//+ DBManager
329+
if (_chat.dbManager.isEnabled()) {
330+
if (await _chat.dbManager.canAddChannel(
331+
query: _query, channelUrl: addedChannel.channelUrl) ==
332+
false) {
333+
return false;
334+
}
335+
}
336+
//- DBManager
329337
}
330-
// }
331338

332339
return true;
333340
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: sendbird_chat_sdk
22
description: With Sendbird Chat for Flutter, you can easily build an in-app chat with all the essential messaging features.
3-
version: 4.2.18
3+
version: 4.2.19
44
homepage: https://sendbird.com
55
repository: https://github.com/sendbird/sendbird-chat-sdk-flutter
66
documentation: https://sendbird.com/docs/chat/sdk/v4/flutter/getting-started/send-first-message

0 commit comments

Comments
 (0)