From dba4a6be4aaa27d1512831eed780b71d2b8d545e Mon Sep 17 00:00:00 2001 From: Alex Demchenko Date: Sun, 3 Apr 2022 14:21:59 +0200 Subject: [PATCH] Fixes after PR --- .metadata | 2 +- CHANGELOG.md | 5 +++++ lib/src/message.dart | 17 ++++++++--------- lib/src/messages/custom_message.dart | 13 +++++++------ lib/src/messages/custom_message.g.dart | 2 ++ lib/src/messages/file_message.dart | 13 +++++++------ lib/src/messages/file_message.g.dart | 2 ++ lib/src/messages/image_message.dart | 13 +++++++------ lib/src/messages/image_message.g.dart | 2 ++ lib/src/messages/text_message.dart | 12 +++++++----- lib/src/messages/text_message.g.dart | 2 ++ lib/src/messages/unsupported_message.dart | 11 +++++------ lib/src/messages/unsupported_message.g.dart | 2 ++ pubspec.yaml | 6 +++--- 14 files changed, 60 insertions(+), 42 deletions(-) diff --git a/.metadata b/.metadata index 85b7017..50694c1 100644 --- a/.metadata +++ b/.metadata @@ -4,7 +4,7 @@ # This file should be version controlled and should not be manually edited. version: - revision: 097d3313d8e2c7f901932d63e537c1acefb87800 + revision: c860cba910319332564e1e9d470a17074c1f2dfd channel: stable project_type: package diff --git a/CHANGELOG.md b/CHANGELOG.md index 058d103..9262cf8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 3.3.2 + +- Add `showStatus` to all messages. Thanks @arsamme for the PR! +- Update to Flutter 2.10.4 + ## 3.3.1 - Update to Flutter 2.10.2 diff --git a/lib/src/message.dart b/lib/src/message.dart index 98f3737..25bcd5a 100644 --- a/lib/src/message.dart +++ b/lib/src/message.dart @@ -1,6 +1,5 @@ import 'package:equatable/equatable.dart'; import 'package:meta/meta.dart'; - import 'messages/custom_message.dart'; import 'messages/file_message.dart'; import 'messages/image_message.dart'; @@ -27,11 +26,11 @@ abstract class Message extends Equatable { this.remoteId, this.repliedMessage, this.roomId, + this.showStatus, this.status, this.type, - this.updatedAt, { - this.showStatus = true, - }); + this.updatedAt, + ); /// Creates a particular message from a map (decoded JSON). /// Type is determined by the `type` field. @@ -57,18 +56,18 @@ abstract class Message extends Equatable { /// both metadatas will be merged into one Map, where keys from a passed /// metadata will overwite keys from the previous one. /// [previewData] will be only set for the text message type. + /// [remoteId], [showStatus] and [updatedAt] with null values will nullify existing value. /// [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). - /// [remoteId] and [updatedAt] with null values will nullify existing value. /// [uri] will be only set for file and image message types. Null value /// will be overwritten by the previous value (uri can't be empty). Message copyWith({ Map? metadata, PreviewData? previewData, String? remoteId, - Status? status, bool? showStatus, + Status? status, String? text, int? updatedAt, String? uri, @@ -98,12 +97,12 @@ abstract class Message extends Equatable { /// ID of the room where this message is sent final String? roomId; + /// Show status or not + final bool? showStatus; + /// Message [Status] final Status? status; - /// Show status or not - final bool showStatus; - /// [MessageType] final MessageType type; diff --git a/lib/src/messages/custom_message.dart b/lib/src/messages/custom_message.dart index 404b7cc..62b4786 100644 --- a/lib/src/messages/custom_message.dart +++ b/lib/src/messages/custom_message.dart @@ -1,6 +1,5 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:meta/meta.dart'; - import '../message.dart'; import '../preview_data.dart' show PreviewData; import '../user.dart' show User; @@ -22,10 +21,10 @@ class CustomMessage extends Message { String? remoteId, Message? repliedMessage, String? roomId, + bool? showStatus, Status? status, MessageType? type, int? updatedAt, - bool showStatus = true, }) : super( author, createdAt, @@ -34,10 +33,10 @@ class CustomMessage extends Message { remoteId, repliedMessage, roomId, + showStatus, status, type ?? MessageType.custom, updatedAt, - showStatus: showStatus, ); /// Creates a full custom message from a partial one. @@ -49,6 +48,7 @@ class CustomMessage extends Message { String? remoteId, Message? repliedMessage, String? roomId, + bool? showStatus, Status? status, int? updatedAt, }) : super( @@ -59,6 +59,7 @@ class CustomMessage extends Message { remoteId, repliedMessage, roomId, + showStatus, status, MessageType.custom, updatedAt, @@ -78,7 +79,7 @@ class CustomMessage extends Message { /// both metadatas will be merged into one Map, where keys from a passed /// metadata will overwite keys from the previous one. /// [previewData] is ignored for this message type. - /// [remoteId] and [updatedAt] with null values will nullify existing value. + /// [remoteId], [showStatus] and [updatedAt] with null values will nullify existing value. /// [status] with null value will be overwritten by the previous status. /// [text] is ignored for this message type. /// [uri] is ignored for this message type. @@ -87,8 +88,8 @@ class CustomMessage extends Message { Map? metadata, PreviewData? previewData, String? remoteId, - Status? status, bool? showStatus, + Status? status, String? text, int? updatedAt, String? uri, @@ -107,7 +108,7 @@ class CustomMessage extends Message { repliedMessage: repliedMessage, roomId: roomId, status: status ?? this.status, - showStatus: showStatus ?? this.showStatus, + showStatus: showStatus, updatedAt: updatedAt, ); } diff --git a/lib/src/messages/custom_message.g.dart b/lib/src/messages/custom_message.g.dart index bcf4025..45aab1a 100644 --- a/lib/src/messages/custom_message.g.dart +++ b/lib/src/messages/custom_message.g.dart @@ -17,6 +17,7 @@ CustomMessage _$CustomMessageFromJson(Map json) => ? null : Message.fromJson(json['repliedMessage'] as Map), roomId: json['roomId'] as String?, + showStatus: json['showStatus'] as bool?, status: $enumDecodeNullable(_$StatusEnumMap, json['status']), type: $enumDecodeNullable(_$MessageTypeEnumMap, json['type']), updatedAt: json['updatedAt'] as int?, @@ -39,6 +40,7 @@ Map _$CustomMessageToJson(CustomMessage instance) { writeNotNull('remoteId', instance.remoteId); writeNotNull('repliedMessage', instance.repliedMessage?.toJson()); writeNotNull('roomId', instance.roomId); + writeNotNull('showStatus', instance.showStatus); writeNotNull('status', _$StatusEnumMap[instance.status]); val['type'] = _$MessageTypeEnumMap[instance.type]; writeNotNull('updatedAt', instance.updatedAt); diff --git a/lib/src/messages/file_message.dart b/lib/src/messages/file_message.dart index cb18616..2997c7c 100644 --- a/lib/src/messages/file_message.dart +++ b/lib/src/messages/file_message.dart @@ -22,12 +22,12 @@ class FileMessage extends Message { String? remoteId, Message? repliedMessage, String? roomId, + bool? showStatus, required this.size, Status? status, MessageType? type, int? updatedAt, required this.uri, - bool showStatus = true, }) : super( author, createdAt, @@ -36,6 +36,7 @@ class FileMessage extends Message { remoteId, repliedMessage, roomId, + showStatus, status, type ?? MessageType.file, updatedAt, @@ -50,9 +51,9 @@ class FileMessage extends Message { String? remoteId, Message? repliedMessage, String? roomId, + bool? showStatus, Status? status, int? updatedAt, - bool showStatus = true, }) : mimeType = partialFile.mimeType, name = partialFile.name, size = partialFile.size, @@ -65,10 +66,10 @@ class FileMessage extends Message { remoteId, repliedMessage, roomId, + showStatus, status, MessageType.file, updatedAt, - showStatus:showStatus, ); /// Creates a file message from a map (decoded JSON). @@ -84,7 +85,7 @@ class FileMessage extends Message { /// both metadatas will be merged into one Map, where keys from a passed /// metadata will overwite keys from the previous one. /// [previewData] is ignored for this message type. - /// [remoteId] and [updatedAt] with null values will nullify existing value. + /// [remoteId], [showStatus] and [updatedAt] with null values will nullify existing value. /// [status] and [uri] with null values will be overwritten by previous values. /// [text] is ignored for this message type. @override @@ -92,8 +93,8 @@ class FileMessage extends Message { Map? metadata, PreviewData? previewData, String? remoteId, - Status? status, bool? showStatus, + Status? status, String? text, int? updatedAt, String? uri, @@ -113,9 +114,9 @@ class FileMessage extends Message { remoteId: remoteId, repliedMessage: repliedMessage, roomId: roomId, + showStatus: showStatus, size: size, status: status ?? this.status, - showStatus: showStatus?? this.showStatus, updatedAt: updatedAt, uri: uri ?? this.uri, ); diff --git a/lib/src/messages/file_message.g.dart b/lib/src/messages/file_message.g.dart index b572322..179770a 100644 --- a/lib/src/messages/file_message.g.dart +++ b/lib/src/messages/file_message.g.dart @@ -18,6 +18,7 @@ FileMessage _$FileMessageFromJson(Map json) => FileMessage( ? null : Message.fromJson(json['repliedMessage'] as Map), roomId: json['roomId'] as String?, + showStatus: json['showStatus'] as bool?, size: json['size'] as num, status: $enumDecodeNullable(_$StatusEnumMap, json['status']), type: $enumDecodeNullable(_$MessageTypeEnumMap, json['type']), @@ -42,6 +43,7 @@ Map _$FileMessageToJson(FileMessage instance) { writeNotNull('remoteId', instance.remoteId); writeNotNull('repliedMessage', instance.repliedMessage?.toJson()); writeNotNull('roomId', instance.roomId); + writeNotNull('showStatus', instance.showStatus); writeNotNull('status', _$StatusEnumMap[instance.status]); val['type'] = _$MessageTypeEnumMap[instance.type]; writeNotNull('updatedAt', instance.updatedAt); diff --git a/lib/src/messages/image_message.dart b/lib/src/messages/image_message.dart index 30b216c..692a082 100644 --- a/lib/src/messages/image_message.dart +++ b/lib/src/messages/image_message.dart @@ -1,6 +1,5 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:meta/meta.dart'; - import '../message.dart'; import '../preview_data.dart' show PreviewData; import '../user.dart' show User; @@ -23,13 +22,13 @@ class ImageMessage extends Message { String? remoteId, Message? repliedMessage, String? roomId, + bool? showStatus, required this.size, Status? status, MessageType? type, int? updatedAt, required this.uri, this.width, - bool showStatus = true, }) : super( author, createdAt, @@ -38,10 +37,10 @@ class ImageMessage extends Message { remoteId, repliedMessage, roomId, + showStatus, status, type ?? MessageType.image, updatedAt, - showStatus: showStatus, ); /// Creates a full image message from a partial one. @@ -53,6 +52,7 @@ class ImageMessage extends Message { String? remoteId, Message? repliedMessage, String? roomId, + bool? showStatus, Status? status, int? updatedAt, }) : height = partialImage.height, @@ -68,6 +68,7 @@ class ImageMessage extends Message { remoteId, repliedMessage, roomId, + showStatus, status, MessageType.image, updatedAt, @@ -86,7 +87,7 @@ class ImageMessage extends Message { /// both metadatas will be merged into one Map, where keys from a passed /// metadata will overwite keys from the previous one. /// [previewData] is ignored for this message type. - /// [remoteId] and [updatedAt] with null values will nullify existing value. + /// [remoteId], [showStatus] and [updatedAt] with null values will nullify existing value. /// [status] and [uri] with null values will be overwritten by previous values. /// [text] is ignored for this message type. @override @@ -94,8 +95,8 @@ class ImageMessage extends Message { Map? metadata, PreviewData? previewData, String? remoteId, - Status? status, bool? showStatus, + Status? status, String? text, int? updatedAt, String? uri, @@ -115,9 +116,9 @@ class ImageMessage extends Message { remoteId: remoteId, repliedMessage: repliedMessage, roomId: roomId, + showStatus: showStatus, size: size, status: status ?? this.status, - showStatus: showStatus?? this.showStatus, updatedAt: updatedAt, uri: uri ?? this.uri, width: width, diff --git a/lib/src/messages/image_message.g.dart b/lib/src/messages/image_message.g.dart index eb5193c..17a3366 100644 --- a/lib/src/messages/image_message.g.dart +++ b/lib/src/messages/image_message.g.dart @@ -18,6 +18,7 @@ ImageMessage _$ImageMessageFromJson(Map json) => ImageMessage( ? null : Message.fromJson(json['repliedMessage'] as Map), roomId: json['roomId'] as String?, + showStatus: json['showStatus'] as bool?, size: json['size'] as num, status: $enumDecodeNullable(_$StatusEnumMap, json['status']), type: $enumDecodeNullable(_$MessageTypeEnumMap, json['type']), @@ -43,6 +44,7 @@ Map _$ImageMessageToJson(ImageMessage instance) { writeNotNull('remoteId', instance.remoteId); writeNotNull('repliedMessage', instance.repliedMessage?.toJson()); writeNotNull('roomId', instance.roomId); + writeNotNull('showStatus', instance.showStatus); writeNotNull('status', _$StatusEnumMap[instance.status]); val['type'] = _$MessageTypeEnumMap[instance.type]; writeNotNull('updatedAt', instance.updatedAt); diff --git a/lib/src/messages/text_message.dart b/lib/src/messages/text_message.dart index b9839f7..dc7585c 100644 --- a/lib/src/messages/text_message.dart +++ b/lib/src/messages/text_message.dart @@ -21,11 +21,11 @@ class TextMessage extends Message { String? remoteId, Message? repliedMessage, String? roomId, + bool? showStatus, Status? status, required this.text, MessageType? type, int? updatedAt, - bool showStatus = true, }) : super( author, createdAt, @@ -34,10 +34,10 @@ class TextMessage extends Message { remoteId, repliedMessage, roomId, + showStatus, status, type ?? MessageType.text, updatedAt, - showStatus: showStatus, ); /// Creates a full text message from a partial one. @@ -49,6 +49,7 @@ class TextMessage extends Message { String? remoteId, Message? repliedMessage, String? roomId, + bool? showStatus, Status? status, int? updatedAt, }) : previewData = partialText.previewData, @@ -61,6 +62,7 @@ class TextMessage extends Message { remoteId, repliedMessage, roomId, + showStatus, status, MessageType.text, updatedAt, @@ -78,7 +80,7 @@ class TextMessage extends Message { /// [metadata] with null value will nullify existing metadata, otherwise /// both metadatas will be merged into one Map, where keys from a passed /// metadata will overwite keys from the previous one. - /// [remoteId] and [updatedAt] with null values will nullify existing value. + /// [previewData], [remoteId], [showStatus] and [updatedAt] with null values will nullify existing value. /// [status] and [text] with null values will be overwritten by previous values. /// [uri] is ignored for this message type. @override @@ -86,8 +88,8 @@ class TextMessage extends Message { Map? metadata, PreviewData? previewData, String? remoteId, - Status? status, bool? showStatus, + Status? status, String? text, int? updatedAt, String? uri, @@ -106,8 +108,8 @@ class TextMessage extends Message { remoteId: remoteId, repliedMessage: repliedMessage, roomId: roomId, + showStatus: showStatus, status: status ?? this.status, - showStatus: showStatus ?? this.showStatus, text: text ?? this.text, updatedAt: updatedAt, ); diff --git a/lib/src/messages/text_message.g.dart b/lib/src/messages/text_message.g.dart index 64a0ae1..dfed0e0 100644 --- a/lib/src/messages/text_message.g.dart +++ b/lib/src/messages/text_message.g.dart @@ -19,6 +19,7 @@ TextMessage _$TextMessageFromJson(Map json) => TextMessage( ? null : Message.fromJson(json['repliedMessage'] as Map), roomId: json['roomId'] as String?, + showStatus: json['showStatus'] as bool?, status: $enumDecodeNullable(_$StatusEnumMap, json['status']), text: json['text'] as String, type: $enumDecodeNullable(_$MessageTypeEnumMap, json['type']), @@ -42,6 +43,7 @@ Map _$TextMessageToJson(TextMessage instance) { writeNotNull('remoteId', instance.remoteId); writeNotNull('repliedMessage', instance.repliedMessage?.toJson()); writeNotNull('roomId', instance.roomId); + writeNotNull('showStatus', instance.showStatus); writeNotNull('status', _$StatusEnumMap[instance.status]); val['type'] = _$MessageTypeEnumMap[instance.type]; writeNotNull('updatedAt', instance.updatedAt); diff --git a/lib/src/messages/unsupported_message.dart b/lib/src/messages/unsupported_message.dart index d2111c2..038a8e0 100644 --- a/lib/src/messages/unsupported_message.dart +++ b/lib/src/messages/unsupported_message.dart @@ -1,6 +1,5 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:meta/meta.dart'; - import '../message.dart'; import '../preview_data.dart' show PreviewData; import '../user.dart' show User; @@ -23,10 +22,10 @@ class UnsupportedMessage extends Message { String? remoteId, Message? repliedMessage, String? roomId, + bool? showStatus, Status? status, MessageType? type, int? updatedAt, - bool showStatus = true, }) : super( author, createdAt, @@ -35,10 +34,10 @@ class UnsupportedMessage extends Message { remoteId, repliedMessage, roomId, + showStatus, status, type ?? MessageType.unsupported, updatedAt, - showStatus: showStatus, ); /// Creates an unsupported message from a map (decoded JSON). @@ -55,7 +54,7 @@ class UnsupportedMessage extends Message { /// both metadatas will be merged into one Map, where keys from a passed /// metadata will overwite keys from the previous one. /// [previewData] is ignored for this message type. - /// [remoteId] and [updatedAt] with null values will nullify existing value. + /// [remoteId], [showStatus] and [updatedAt] with null values will nullify existing value. /// [status] with null value will be overwritten by the previous status. /// [text] is ignored for this message type. /// [uri] is ignored for this message type. @@ -64,8 +63,8 @@ class UnsupportedMessage extends Message { Map? metadata, PreviewData? previewData, String? remoteId, - Status? status, bool? showStatus, + Status? status, String? text, int? updatedAt, String? uri, @@ -83,8 +82,8 @@ class UnsupportedMessage extends Message { remoteId: remoteId, repliedMessage: repliedMessage, roomId: roomId, + showStatus: showStatus, status: status ?? this.status, - showStatus: showStatus ?? this.showStatus, updatedAt: updatedAt, ); } diff --git a/lib/src/messages/unsupported_message.g.dart b/lib/src/messages/unsupported_message.g.dart index f174ef2..5c8a95c 100644 --- a/lib/src/messages/unsupported_message.g.dart +++ b/lib/src/messages/unsupported_message.g.dart @@ -17,6 +17,7 @@ UnsupportedMessage _$UnsupportedMessageFromJson(Map json) => ? null : Message.fromJson(json['repliedMessage'] as Map), roomId: json['roomId'] as String?, + showStatus: json['showStatus'] as bool?, status: $enumDecodeNullable(_$StatusEnumMap, json['status']), type: $enumDecodeNullable(_$MessageTypeEnumMap, json['type']), updatedAt: json['updatedAt'] as int?, @@ -39,6 +40,7 @@ Map _$UnsupportedMessageToJson(UnsupportedMessage instance) { writeNotNull('remoteId', instance.remoteId); writeNotNull('repliedMessage', instance.repliedMessage?.toJson()); writeNotNull('roomId', instance.roomId); + writeNotNull('showStatus', instance.showStatus); writeNotNull('status', _$StatusEnumMap[instance.status]); val['type'] = _$MessageTypeEnumMap[instance.type]; writeNotNull('updatedAt', instance.updatedAt); diff --git a/pubspec.yaml b/pubspec.yaml index d0a77fc..379cdc8 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.3.1 +version: 3.3.2 homepage: https://flyer.chat repository: https://github.com/flyerhq/flutter_chat_types @@ -15,6 +15,6 @@ dependencies: meta: ^1.7.0 dev_dependencies: - build_runner: ^2.1.7 + build_runner: ^2.1.8 flutter_lints: ^1.0.4 - json_serializable: ^6.1.4 + json_serializable: ^6.1.5