Skip to content

Commit

Permalink
Merge pull request #74 from sendbird/v4.0.7
Browse files Browse the repository at this point in the history
Add 4.0.7.
  • Loading branch information
sf-tyler-jeong authored Aug 18, 2023
2 parents 9c76d58 + eebd520 commit f022b55
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 4 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
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.6
sendbird_chat_sdk: ^4.0.7
```
- Run `flutter pub get` command in your project directory.
Expand Down
1 change: 1 addition & 0 deletions lib/sendbird_chat_sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
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 @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions lib/src/public/core/channel/feed_channel/feed_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ class FeedChannel extends BaseChannel {
final channel = chat.channelCache.find<FeedChannel>(channelKey: channelUrl);
if (channel != null && !channel.dirty) {
channel.fromCache = true;
channel.groupChannel.fromCache = true;
return channel;
}
return await FeedChannel.refresh(channelUrl, chat: chat);
Expand Down
31 changes: 31 additions & 0 deletions lib/src/public/core/message/base_message.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -146,6 +149,11 @@ abstract class BaseMessage {
@JsonKey(name: "extended_message", defaultValue: {})
Map<String, dynamic> extendedMessage;

/// notificationData
/// @since 4.0.7
@JsonKey(includeFromJson: false, includeToJson: false)
NotificationData? notificationData;

final bool forceUpdateLastMessage;

@JsonKey(includeFromJson: false, includeToJson: false)
Expand Down Expand Up @@ -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<String, dynamic>? subDataMap = jsonDecode(subData);
if (subDataMap != null) {
final Map<String, String>? templateVariablesMap =
(subDataMap['template_variables'] as Map<String, dynamic>?)
?.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;
}
}
25 changes: 25 additions & 0 deletions lib/src/public/main/model/message/notification_data.dart
Original file line number Diff line number Diff line change
@@ -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<String, String> templateVariables;

/// label
/// @since 4.0.7
String? label;

NotificationData({
required this.templateKey,
required this.templateVariables,
this.label,
});
}
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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'
Expand Down

0 comments on commit f022b55

Please sign in to comment.