Skip to content

Commit

Permalink
Merge pull request #104 from sendbird/v4.2.11
Browse files Browse the repository at this point in the history
Add 4.2.11.
  • Loading branch information
sf-tyler-jeong authored Apr 18, 2024
2 parents ce0be85 + b9ef8de commit 2cc785f
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 34 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
## v4.2.11 (Apr 18, 2024)

### Improvements
- Fixed the bug that there are duplicate channels in `GroupChannelCollection`
- Added default mimeType in `FileMessageCreateParams`

## v4.2.10 (Apr 9, 2024)

### Features
- Added the privacy manifest file for iOS

### Improvements
- Fixed the bug that there are duplicated channels in `GroupChannelCollection`
- Fixed the bug that there are duplicate channels in `GroupChannelCollection`

## v4.2.9 (Apr 3, 2024)

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.10
sendbird_chat_sdk: ^4.2.11
```
- 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 @@ -60,7 +60,7 @@ part 'chat_notifications.dart';
part 'chat_push.dart';
part 'chat_user.dart';

const sdkVersion = '4.2.10';
const sdkVersion = '4.2.11';

// Internal implementation for main class. Do not directly access this class.
class Chat with WidgetsBindingObserver {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,7 @@ extension GroupChannelCollectionManager on CollectionManager {

if (addedChannels != null && addedChannels.isNotEmpty) {
for (final addedChannel in addedChannels) {
bool isChannelExists = false;
for (final channel in channelCollection.channelList) {
if (channel.channelUrl == addedChannel.channelUrl) {
isChannelExists = true;
break;
}
}

if (!isChannelExists) {
if (!_isChannelExists(channelCollection, addedChannel.channelUrl)) {
if (await channelCollection.canAddChannel(
eventSource, addedChannel)) {
addedChannelsForEvent.add(addedChannel);
Expand All @@ -187,7 +179,7 @@ extension GroupChannelCollectionManager on CollectionManager {
}

if (addedChannelsForEvent.isNotEmpty) {
channelCollection.channelList.addAll(addedChannelsForEvent);
_addChannel(channelCollection, addedChannelsForEvent);
}
}

Expand Down Expand Up @@ -220,15 +212,7 @@ extension GroupChannelCollectionManager on CollectionManager {

if (eventSource == CollectionEventSource.channelChangeLogs &&
!isUpdatedChannelInChannelList) {
bool isChannelExists = false;
for (final channel in channelCollection.channelList) {
if (channel.channelUrl == updatedChannel.channelUrl) {
isChannelExists = true;
break;
}
}

if (!isChannelExists) {
if (!_isChannelExists(channelCollection, updatedChannel.channelUrl)) {
if (await channelCollection.canAddChannel(
eventSource, updatedChannel)) {
addedChannelsForEvent.add(updatedChannel);
Expand All @@ -238,7 +222,7 @@ extension GroupChannelCollectionManager on CollectionManager {
}

if (addedChannelsForEvent.isNotEmpty) {
channelCollection.channelList.addAll(addedChannelsForEvent);
_addChannel(channelCollection, addedChannelsForEvent);
}
}

Expand Down Expand Up @@ -282,4 +266,36 @@ extension GroupChannelCollectionManager on CollectionManager {
}
}
}

bool _isChannelExists(GroupChannelCollection collection, String channelUrl) {
for (final channel in collection.channelList) {
if (channel.channelUrl == channelUrl) {
return true;
}
}
return false;
}

void _addChannel(
GroupChannelCollection channelCollection,
List<GroupChannel> addedChannels,
) {
final channelList = channelCollection.channelList;
for (final addedChannel in addedChannels) {
bool isUpdated = false;

for (int index = 0; index < channelList.length; index++) {
final channel = channelList[index];
if (addedChannel.channelUrl == channel.channelUrl) {
channelList[index] = addedChannel;
isUpdated = true;
break;
}
}

if (isUpdated == false) {
channelList.add(addedChannel);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,15 @@ class GroupChannelCollection {
GroupChannel addedChannel, {
bool checkToUpdateChannel = false,
}) async {
if (_isLoadedOnce == false) {
return false;
}

if (eventSource == CollectionEventSource.channelCacheLoadMore ||
eventSource == CollectionEventSource.channelLoadMore) {
return true;
}

if (_isLoadedOnce == false) {
return false;
}

if (channelList.isNotEmpty && hasMore) {
final a = channelList.last;
final b = addedChannel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ class FileMessageCreateParams extends BaseMessageCreateParams {
break;
}
} else {
fileMimeType = lookupMimeType(file.path)!;
fileMimeType = lookupMimeType(file.path);
}

fileInfo = FileInfo.fromFile(
fileName: fileName ?? 'file',
file: file,
mimeType: fileMimeType,
mimeType: fileMimeType ?? 'application/octet-stream',
);
}

Expand Down Expand Up @@ -99,7 +99,8 @@ class FileMessageCreateParams extends BaseMessageCreateParams {
pushNotificationDeliveryOption: pushNotificationDeliveryOption,
isPinnedMessage: isPinnedMessage,
) {
String? fileMimeType = lookupMimeType('', headerBytes: fileBytes);
final fileMimeType = lookupMimeType('', headerBytes: fileBytes);

if (fileMimeType != null) {
mimeType = fileMimeType;
} else if (mimeType == null) {
Expand All @@ -109,7 +110,7 @@ class FileMessageCreateParams extends BaseMessageCreateParams {
fileInfo = FileInfo.fromFileBytes(
fileBytes: fileBytes,
fileName: fileName ?? 'file',
mimeType: mimeType,
mimeType: mimeType ?? 'application/octet-stream',
);
}

Expand All @@ -130,8 +131,8 @@ class FileMessageCreateParams extends BaseMessageCreateParams {
PushNotificationDeliveryOption.normal,
bool isPinnedMessage = false,
}) : fileInfo = FileInfo.fromFileUrl(
fileName: fileName ?? 'image',
mimeType: mimeType ?? 'image/jpeg',
fileName: fileName ?? 'file',
mimeType: mimeType ?? 'application/octet-stream',
fileUrl: fileUrl,
fileSize: fileSize,
),
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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.2.10
version: 4.2.11
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
Expand Down

0 comments on commit 2cc785f

Please sign in to comment.