From a402a8cc6af860f2b155c8b3e68450200237d80e Mon Sep 17 00:00:00 2001 From: Alex Demchenko Date: Mon, 27 Sep 2021 15:28:20 +0200 Subject: [PATCH] Add remoteId --- CHANGELOG.md | 4 ++++ lib/src/message.dart | 7 ++++++- lib/src/messages/custom_message.dart | 8 +++++++- lib/src/messages/custom_message.g.dart | 2 ++ lib/src/messages/file_message.dart | 8 +++++++- lib/src/messages/file_message.g.dart | 2 ++ lib/src/messages/image_message.dart | 8 +++++++- lib/src/messages/image_message.g.dart | 2 ++ lib/src/messages/text_message.dart | 8 +++++++- lib/src/messages/text_message.g.dart | 2 ++ lib/src/messages/unsupported_message.dart | 6 +++++- lib/src/messages/unsupported_message.g.dart | 2 ++ pubspec.yaml | 2 +- 13 files changed, 54 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ffa982c..f611110 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 3.1.3 + +- Add `remoteId` message property + ## 3.1.2 - Additionally, revert `json_annotation` upgrade diff --git a/lib/src/message.dart b/lib/src/message.dart index 1a3fecf..2117517 100644 --- a/lib/src/message.dart +++ b/lib/src/message.dart @@ -23,6 +23,7 @@ abstract class Message extends Equatable { this.createdAt, this.id, this.metadata, + this.remoteId, this.roomId, this.status, this.type, @@ -56,10 +57,11 @@ abstract class Message extends Equatable { /// [status] with null value will be overwritten by the previous status. /// [text] will be only set for the text message type. Null value will be /// overwritten by the previous text (can't be empty). - /// [updatedAt] with null value will nullify existing value. + /// [remoteId] and [updatedAt] with null value will nullify existing value. Message copyWith({ Map? metadata, PreviewData? previewData, + String? remoteId, Status? status, String? text, int? updatedAt, @@ -80,6 +82,9 @@ abstract class Message extends Equatable { /// Additional custom metadata or attributes related to the message final Map? metadata; + /// Unique ID of the message received from the backend + final String? remoteId; + /// ID of the room where this message is sent final String? roomId; diff --git a/lib/src/messages/custom_message.dart b/lib/src/messages/custom_message.dart index 490f7d7..0b0b304 100644 --- a/lib/src/messages/custom_message.dart +++ b/lib/src/messages/custom_message.dart @@ -18,6 +18,7 @@ class CustomMessage extends Message { int? createdAt, required String id, Map? metadata, + String? remoteId, String? roomId, Status? status, MessageType? type, @@ -27,6 +28,7 @@ class CustomMessage extends Message { createdAt, id, metadata, + remoteId, roomId, status, type ?? MessageType.custom, @@ -39,6 +41,7 @@ class CustomMessage extends Message { int? createdAt, required String id, required PartialCustom partialCustom, + String? remoteId, String? roomId, Status? status, int? updatedAt, @@ -47,6 +50,7 @@ class CustomMessage extends Message { createdAt, id, partialCustom.metadata, + remoteId, roomId, status, MessageType.custom, @@ -69,11 +73,12 @@ class CustomMessage extends Message { /// [previewData] is ignored for this message type. /// [status] with null value will be overwritten by the previous status. /// [text] is ignored for this message type. - /// [updatedAt] with null value will nullify existing value. + /// [remoteId] and [updatedAt] with null value will nullify existing value. @override Message copyWith({ Map? metadata, PreviewData? previewData, + String? remoteId, Status? status, String? text, int? updatedAt, @@ -88,6 +93,7 @@ class CustomMessage extends Message { ...this.metadata ?? {}, ...metadata, }, + remoteId: remoteId, roomId: roomId, status: status ?? this.status, updatedAt: updatedAt, diff --git a/lib/src/messages/custom_message.g.dart b/lib/src/messages/custom_message.g.dart index 084d11f..82949e7 100644 --- a/lib/src/messages/custom_message.g.dart +++ b/lib/src/messages/custom_message.g.dart @@ -12,6 +12,7 @@ CustomMessage _$CustomMessageFromJson(Map json) => createdAt: json['createdAt'] as int?, id: json['id'] as String, metadata: json['metadata'] as Map?, + remoteId: json['remoteId'] as String?, roomId: json['roomId'] as String?, status: _$enumDecodeNullable(_$StatusEnumMap, json['status']), type: _$enumDecodeNullable(_$MessageTypeEnumMap, json['type']), @@ -24,6 +25,7 @@ Map _$CustomMessageToJson(CustomMessage instance) => 'createdAt': instance.createdAt, 'id': instance.id, 'metadata': instance.metadata, + 'remoteId': instance.remoteId, 'roomId': instance.roomId, 'status': _$StatusEnumMap[instance.status], 'type': _$MessageTypeEnumMap[instance.type], diff --git a/lib/src/messages/file_message.dart b/lib/src/messages/file_message.dart index 612b12b..be43702 100644 --- a/lib/src/messages/file_message.dart +++ b/lib/src/messages/file_message.dart @@ -19,6 +19,7 @@ class FileMessage extends Message { Map? metadata, this.mimeType, required this.name, + String? remoteId, String? roomId, required this.size, Status? status, @@ -30,6 +31,7 @@ class FileMessage extends Message { createdAt, id, metadata, + remoteId, roomId, status, type ?? MessageType.file, @@ -42,6 +44,7 @@ class FileMessage extends Message { int? createdAt, required String id, required PartialFile partialFile, + String? remoteId, String? roomId, Status? status, int? updatedAt, @@ -54,6 +57,7 @@ class FileMessage extends Message { createdAt, id, partialFile.metadata, + remoteId, roomId, status, MessageType.file, @@ -75,11 +79,12 @@ class FileMessage extends Message { /// [previewData] is ignored for this message type. /// [status] with null value will be overwritten by the previous status. /// [text] is ignored for this message type. - /// [updatedAt] with null value will nullify existing value. + /// [remoteId] and [updatedAt] with null value will nullify existing value. @override Message copyWith({ Map? metadata, PreviewData? previewData, + String? remoteId, Status? status, String? text, int? updatedAt, @@ -96,6 +101,7 @@ class FileMessage extends Message { }, mimeType: mimeType, name: name, + remoteId: remoteId, roomId: roomId, size: size, status: status ?? this.status, diff --git a/lib/src/messages/file_message.g.dart b/lib/src/messages/file_message.g.dart index e1e7aca..c84e655 100644 --- a/lib/src/messages/file_message.g.dart +++ b/lib/src/messages/file_message.g.dart @@ -13,6 +13,7 @@ FileMessage _$FileMessageFromJson(Map json) => FileMessage( metadata: json['metadata'] as Map?, mimeType: json['mimeType'] as String?, name: json['name'] as String, + remoteId: json['remoteId'] as String?, roomId: json['roomId'] as String?, size: json['size'] as num, status: _$enumDecodeNullable(_$StatusEnumMap, json['status']), @@ -27,6 +28,7 @@ Map _$FileMessageToJson(FileMessage instance) => 'createdAt': instance.createdAt, 'id': instance.id, 'metadata': instance.metadata, + 'remoteId': instance.remoteId, 'roomId': instance.roomId, 'status': _$StatusEnumMap[instance.status], 'type': _$MessageTypeEnumMap[instance.type], diff --git a/lib/src/messages/image_message.dart b/lib/src/messages/image_message.dart index 45ef1df..18ad1d4 100644 --- a/lib/src/messages/image_message.dart +++ b/lib/src/messages/image_message.dart @@ -19,6 +19,7 @@ class ImageMessage extends Message { required String id, Map? metadata, required this.name, + String? remoteId, String? roomId, required this.size, Status? status, @@ -31,6 +32,7 @@ class ImageMessage extends Message { createdAt, id, metadata, + remoteId, roomId, status, type ?? MessageType.image, @@ -43,6 +45,7 @@ class ImageMessage extends Message { int? createdAt, required String id, required PartialImage partialImage, + String? remoteId, String? roomId, Status? status, int? updatedAt, @@ -56,6 +59,7 @@ class ImageMessage extends Message { createdAt, id, partialImage.metadata, + remoteId, roomId, status, MessageType.image, @@ -77,11 +81,12 @@ class ImageMessage extends Message { /// [previewData] is ignored for this message type. /// [status] with null value will be overwritten by the previous status. /// [text] is ignored for this message type. - /// [updatedAt] with null value will nullify existing value. + /// [remoteId] and [updatedAt] with null value will nullify existing value. @override Message copyWith({ Map? metadata, PreviewData? previewData, + String? remoteId, Status? status, String? text, int? updatedAt, @@ -98,6 +103,7 @@ class ImageMessage extends Message { ...this.metadata ?? {}, ...metadata, }, + remoteId: remoteId, roomId: roomId, size: size, status: status ?? this.status, diff --git a/lib/src/messages/image_message.g.dart b/lib/src/messages/image_message.g.dart index d324f46..261249c 100644 --- a/lib/src/messages/image_message.g.dart +++ b/lib/src/messages/image_message.g.dart @@ -13,6 +13,7 @@ ImageMessage _$ImageMessageFromJson(Map json) => ImageMessage( id: json['id'] as String, metadata: json['metadata'] as Map?, name: json['name'] as String, + remoteId: json['remoteId'] as String?, roomId: json['roomId'] as String?, size: json['size'] as num, status: _$enumDecodeNullable(_$StatusEnumMap, json['status']), @@ -28,6 +29,7 @@ Map _$ImageMessageToJson(ImageMessage instance) => 'createdAt': instance.createdAt, 'id': instance.id, 'metadata': instance.metadata, + 'remoteId': instance.remoteId, 'roomId': instance.roomId, 'status': _$StatusEnumMap[instance.status], 'type': _$MessageTypeEnumMap[instance.type], diff --git a/lib/src/messages/text_message.dart b/lib/src/messages/text_message.dart index 1e5eb44..38090ad 100644 --- a/lib/src/messages/text_message.dart +++ b/lib/src/messages/text_message.dart @@ -18,6 +18,7 @@ class TextMessage extends Message { required String id, Map? metadata, this.previewData, + String? remoteId, String? roomId, Status? status, required this.text, @@ -28,6 +29,7 @@ class TextMessage extends Message { createdAt, id, metadata, + remoteId, roomId, status, type ?? MessageType.text, @@ -40,6 +42,7 @@ class TextMessage extends Message { int? createdAt, required String id, required PartialText partialText, + String? remoteId, String? roomId, Status? status, int? updatedAt, @@ -50,6 +53,7 @@ class TextMessage extends Message { createdAt, id, partialText.metadata, + remoteId, roomId, status, MessageType.text, @@ -69,11 +73,12 @@ class TextMessage extends Message { /// both metadatas will be merged into one Map, where keys from a passed /// metadata will overwite keys from the previous one. /// [status] with null value will be overwritten by the previous status. - /// [updatedAt] with null value will nullify existing value. + /// [remoteId] and [updatedAt] with null value will nullify existing value. @override Message copyWith({ Map? metadata, PreviewData? previewData, + String? remoteId, Status? status, String? text, int? updatedAt, @@ -89,6 +94,7 @@ class TextMessage extends Message { ...metadata, }, previewData: previewData, + remoteId: remoteId, roomId: roomId, status: status ?? this.status, text: text ?? this.text, diff --git a/lib/src/messages/text_message.g.dart b/lib/src/messages/text_message.g.dart index f5aff3e..13839f4 100644 --- a/lib/src/messages/text_message.g.dart +++ b/lib/src/messages/text_message.g.dart @@ -14,6 +14,7 @@ TextMessage _$TextMessageFromJson(Map json) => TextMessage( previewData: json['previewData'] == null ? null : PreviewData.fromJson(json['previewData'] as Map), + remoteId: json['remoteId'] as String?, roomId: json['roomId'] as String?, status: _$enumDecodeNullable(_$StatusEnumMap, json['status']), text: json['text'] as String, @@ -27,6 +28,7 @@ Map _$TextMessageToJson(TextMessage instance) => 'createdAt': instance.createdAt, 'id': instance.id, 'metadata': instance.metadata, + 'remoteId': instance.remoteId, 'roomId': instance.roomId, 'status': _$StatusEnumMap[instance.status], 'type': _$MessageTypeEnumMap[instance.type], diff --git a/lib/src/messages/unsupported_message.dart b/lib/src/messages/unsupported_message.dart index 56fdeed..ed727f0 100644 --- a/lib/src/messages/unsupported_message.dart +++ b/lib/src/messages/unsupported_message.dart @@ -19,6 +19,7 @@ class UnsupportedMessage extends Message { int? createdAt, required String id, Map? metadata, + String? remoteId, String? roomId, Status? status, MessageType? type, @@ -28,6 +29,7 @@ class UnsupportedMessage extends Message { createdAt, id, metadata, + remoteId, roomId, status, type ?? MessageType.unsupported, @@ -50,11 +52,12 @@ class UnsupportedMessage extends Message { /// [previewData] is ignored for this message type. /// [status] with null value will be overwritten by the previous status. /// [text] is ignored for this message type. - /// [updatedAt] with null value will nullify existing value. + /// [remoteId] and [updatedAt] with null value will nullify existing value. @override Message copyWith({ Map? metadata, PreviewData? previewData, + String? remoteId, Status? status, String? text, int? updatedAt, @@ -69,6 +72,7 @@ class UnsupportedMessage extends Message { ...this.metadata ?? {}, ...metadata, }, + remoteId: remoteId, roomId: roomId, status: status ?? this.status, updatedAt: updatedAt, diff --git a/lib/src/messages/unsupported_message.g.dart b/lib/src/messages/unsupported_message.g.dart index 8055d33..44d5dad 100644 --- a/lib/src/messages/unsupported_message.g.dart +++ b/lib/src/messages/unsupported_message.g.dart @@ -12,6 +12,7 @@ UnsupportedMessage _$UnsupportedMessageFromJson(Map json) => createdAt: json['createdAt'] as int?, id: json['id'] as String, metadata: json['metadata'] as Map?, + remoteId: json['remoteId'] as String?, roomId: json['roomId'] as String?, status: _$enumDecodeNullable(_$StatusEnumMap, json['status']), type: _$enumDecodeNullable(_$MessageTypeEnumMap, json['type']), @@ -24,6 +25,7 @@ Map _$UnsupportedMessageToJson(UnsupportedMessage instance) => 'createdAt': instance.createdAt, 'id': instance.id, 'metadata': instance.metadata, + 'remoteId': instance.remoteId, 'roomId': instance.roomId, 'status': _$StatusEnumMap[instance.status], 'type': _$MessageTypeEnumMap[instance.type], diff --git a/pubspec.yaml b/pubspec.yaml index ac92f42..b4200cf 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: flutter_chat_types description: > Utility library for the flutter_chat_ui and flutter_firebase_chat_core libraries which contains shared type declarations. -version: 3.1.2 +version: 3.1.3 homepage: https://flyer.chat repository: https://github.com/flyerhq/flutter_chat_types