From eebd5204e0c93a94749533da003c8bc1887b0b16 Mon Sep 17 00:00:00 2001 From: Tyler Jeong Date: Fri, 18 Aug 2023 11:29:49 +0900 Subject: [PATCH] Add 4.0.7. --- CHANGELOG.md | 8 +++++ README.md | 2 +- lib/sendbird_chat_sdk.dart | 1 + lib/src/internal/main/chat/chat.dart | 2 +- .../channel/feed_channel/feed_channel.dart | 1 + lib/src/public/core/message/base_message.dart | 31 +++++++++++++++++++ .../main/model/message/notification_data.dart | 25 +++++++++++++++ pubspec.yaml | 4 +-- 8 files changed, 70 insertions(+), 4 deletions(-) create mode 100644 lib/src/public/main/model/message/notification_data.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index 14eb5998..0d84ea8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## v4.0.7 (Aug 18, 2023) + +### Features +- Added `notificationData` in `BaseMessage`. + +### Improvements +- Fixed the bug regarding `unreadMessageCount` in `FeedChannel`. + ## v4.0.6 (Aug 16, 2023) ### Features diff --git a/README.md b/README.md index d459e5ef..6fba0e84 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Before installing Sendbird Chat SDK, you need to create a Sendbird application o ```yaml dependencies: - sendbird_chat_sdk: ^4.0.6 + sendbird_chat_sdk: ^4.0.7 ``` - Run `flutter pub get` command in your project directory. diff --git a/lib/sendbird_chat_sdk.dart b/lib/sendbird_chat_sdk.dart index 359d774a..09cbc879 100644 --- a/lib/sendbird_chat_sdk.dart +++ b/lib/sendbird_chat_sdk.dart @@ -58,6 +58,7 @@ export 'src/public/main/model/info/scheduled_info.dart'; export 'src/public/main/model/message/apple_critical_alert_options.dart'; export 'src/public/main/model/message/message_change_logs.dart'; export 'src/public/main/model/message/message_meta_array.dart'; +export 'src/public/main/model/message/notification_data.dart'; export 'src/public/main/model/message/unread_message_count.dart'; export 'src/public/main/model/og/og_image.dart'; export 'src/public/main/model/og/og_meta_data.dart'; diff --git a/lib/src/internal/main/chat/chat.dart b/lib/src/internal/main/chat/chat.dart index 068be41f..67a8fba4 100644 --- a/lib/src/internal/main/chat/chat.dart +++ b/lib/src/internal/main/chat/chat.dart @@ -58,7 +58,7 @@ part 'chat_notifications.dart'; part 'chat_push.dart'; part 'chat_user.dart'; -const sdkVersion = '4.0.6'; +const sdkVersion = '4.0.7'; // Internal implementation for main class. Do not directly access this class. class Chat with WidgetsBindingObserver { diff --git a/lib/src/public/core/channel/feed_channel/feed_channel.dart b/lib/src/public/core/channel/feed_channel/feed_channel.dart index 8a19544c..96ac270f 100644 --- a/lib/src/public/core/channel/feed_channel/feed_channel.dart +++ b/lib/src/public/core/channel/feed_channel/feed_channel.dart @@ -153,6 +153,7 @@ class FeedChannel extends BaseChannel { final channel = chat.channelCache.find(channelKey: channelUrl); if (channel != null && !channel.dirty) { channel.fromCache = true; + channel.groupChannel.fromCache = true; return channel; } return await FeedChannel.refresh(channelUrl, chat: chat); diff --git a/lib/src/public/core/message/base_message.dart b/lib/src/public/core/message/base_message.dart index b0021af6..87e9c9d2 100644 --- a/lib/src/public/core/message/base_message.dart +++ b/lib/src/public/core/message/base_message.dart @@ -1,5 +1,7 @@ // Copyright (c) 2023 Sendbird, Inc. All rights reserved. +import 'dart:convert'; + import 'package:collection/collection.dart'; import 'package:json_annotation/json_annotation.dart'; import 'package:sendbird_chat_sdk/src/internal/main/chat/chat.dart'; @@ -25,6 +27,7 @@ import 'package:sendbird_chat_sdk/src/public/main/define/sendbird_error.dart'; import 'package:sendbird_chat_sdk/src/public/main/handler/channel_handler.dart'; import 'package:sendbird_chat_sdk/src/public/main/model/info/scheduled_info.dart'; import 'package:sendbird_chat_sdk/src/public/main/model/message/message_meta_array.dart'; +import 'package:sendbird_chat_sdk/src/public/main/model/message/notification_data.dart'; import 'package:sendbird_chat_sdk/src/public/main/model/og/og_meta_data.dart'; import 'package:sendbird_chat_sdk/src/public/main/model/reaction/reaction.dart'; import 'package:sendbird_chat_sdk/src/public/main/model/reaction/reaction_event.dart'; @@ -146,6 +149,11 @@ abstract class BaseMessage { @JsonKey(name: "extended_message", defaultValue: {}) Map extendedMessage; + /// notificationData + /// @since 4.0.7 + @JsonKey(includeFromJson: false, includeToJson: false) + NotificationData? notificationData; + final bool forceUpdateLastMessage; @JsonKey(includeFromJson: false, includeToJson: false) @@ -558,6 +566,29 @@ abstract class BaseMessage { return MessageMetaArray(key: e, value: value); }).toList(); } + + // notificationData + if (message.extendedMessage.isNotEmpty) { + if (message.extendedMessage['sub_type'] != null && + (message.extendedMessage['sub_type'] as int) == 0) { + final subData = message.extendedMessage['sub_data']; + if (subData != null) { + Map? subDataMap = jsonDecode(subData); + if (subDataMap != null) { + final Map? templateVariablesMap = + (subDataMap['template_variables'] as Map?) + ?.map((key, value) => MapEntry(key, value as String)); + + message.notificationData = NotificationData( + templateKey: subDataMap['template_key'] as String? ?? '', + templateVariables: templateVariablesMap ?? {}, + label: subDataMap['label'] as String?, + ); + } + } + } + } + return message as T; } } diff --git a/lib/src/public/main/model/message/notification_data.dart b/lib/src/public/main/model/message/notification_data.dart new file mode 100644 index 00000000..103c6560 --- /dev/null +++ b/lib/src/public/main/model/message/notification_data.dart @@ -0,0 +1,25 @@ +// Copyright (c) 2023 Sendbird, Inc. All rights reserved. + +import 'package:sendbird_chat_sdk/src/public/core/message/base_message.dart'; + +/// The NotificationData class for [BaseMessage.notificationData]. +/// @since 4.0.7 +class NotificationData { + /// templateKey + /// @since 4.0.7 + final String templateKey; + + /// templateVariables + /// @since 4.0.7 + final Map templateVariables; + + /// label + /// @since 4.0.7 + String? label; + + NotificationData({ + required this.templateKey, + required this.templateVariables, + this.label, + }); +} diff --git a/pubspec.yaml b/pubspec.yaml index 178dda14..5c4c8ff9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,9 +1,9 @@ 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.0.6 +version: 4.0.7 homepage: https://sendbird.com repository: https://github.com/sendbird/sendbird-chat-sdk-flutter -documentation: https://sendbird.com/docs/chat/v4/flutter/getting-started/send-first-message +documentation: https://sendbird.com/docs/chat/sdk/v4/flutter/getting-started/send-first-message environment: sdk: '>=2.19.0 <4.0.0'