Skip to content

Commit

Permalink
Add remoteId
Browse files Browse the repository at this point in the history
  • Loading branch information
demchenkoalex committed Sep 27, 2021
1 parent 7b26125 commit a402a8c
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.1.3

- Add `remoteId` message property

## 3.1.2

- Additionally, revert `json_annotation` upgrade
Expand Down
7 changes: 6 additions & 1 deletion lib/src/message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ abstract class Message extends Equatable {
this.createdAt,
this.id,
this.metadata,
this.remoteId,
this.roomId,
this.status,
this.type,
Expand Down Expand Up @@ -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<String, dynamic>? metadata,
PreviewData? previewData,
String? remoteId,
Status? status,
String? text,
int? updatedAt,
Expand All @@ -80,6 +82,9 @@ abstract class Message extends Equatable {
/// Additional custom metadata or attributes related to the message
final Map<String, dynamic>? 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;

Expand Down
8 changes: 7 additions & 1 deletion lib/src/messages/custom_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class CustomMessage extends Message {
int? createdAt,
required String id,
Map<String, dynamic>? metadata,
String? remoteId,
String? roomId,
Status? status,
MessageType? type,
Expand All @@ -27,6 +28,7 @@ class CustomMessage extends Message {
createdAt,
id,
metadata,
remoteId,
roomId,
status,
type ?? MessageType.custom,
Expand All @@ -39,6 +41,7 @@ class CustomMessage extends Message {
int? createdAt,
required String id,
required PartialCustom partialCustom,
String? remoteId,
String? roomId,
Status? status,
int? updatedAt,
Expand All @@ -47,6 +50,7 @@ class CustomMessage extends Message {
createdAt,
id,
partialCustom.metadata,
remoteId,
roomId,
status,
MessageType.custom,
Expand All @@ -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<String, dynamic>? metadata,
PreviewData? previewData,
String? remoteId,
Status? status,
String? text,
int? updatedAt,
Expand All @@ -88,6 +93,7 @@ class CustomMessage extends Message {
...this.metadata ?? {},
...metadata,
},
remoteId: remoteId,
roomId: roomId,
status: status ?? this.status,
updatedAt: updatedAt,
Expand Down
2 changes: 2 additions & 0 deletions lib/src/messages/custom_message.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion lib/src/messages/file_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class FileMessage extends Message {
Map<String, dynamic>? metadata,
this.mimeType,
required this.name,
String? remoteId,
String? roomId,
required this.size,
Status? status,
Expand All @@ -30,6 +31,7 @@ class FileMessage extends Message {
createdAt,
id,
metadata,
remoteId,
roomId,
status,
type ?? MessageType.file,
Expand All @@ -42,6 +44,7 @@ class FileMessage extends Message {
int? createdAt,
required String id,
required PartialFile partialFile,
String? remoteId,
String? roomId,
Status? status,
int? updatedAt,
Expand All @@ -54,6 +57,7 @@ class FileMessage extends Message {
createdAt,
id,
partialFile.metadata,
remoteId,
roomId,
status,
MessageType.file,
Expand All @@ -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<String, dynamic>? metadata,
PreviewData? previewData,
String? remoteId,
Status? status,
String? text,
int? updatedAt,
Expand All @@ -96,6 +101,7 @@ class FileMessage extends Message {
},
mimeType: mimeType,
name: name,
remoteId: remoteId,
roomId: roomId,
size: size,
status: status ?? this.status,
Expand Down
2 changes: 2 additions & 0 deletions lib/src/messages/file_message.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion lib/src/messages/image_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class ImageMessage extends Message {
required String id,
Map<String, dynamic>? metadata,
required this.name,
String? remoteId,
String? roomId,
required this.size,
Status? status,
Expand All @@ -31,6 +32,7 @@ class ImageMessage extends Message {
createdAt,
id,
metadata,
remoteId,
roomId,
status,
type ?? MessageType.image,
Expand All @@ -43,6 +45,7 @@ class ImageMessage extends Message {
int? createdAt,
required String id,
required PartialImage partialImage,
String? remoteId,
String? roomId,
Status? status,
int? updatedAt,
Expand All @@ -56,6 +59,7 @@ class ImageMessage extends Message {
createdAt,
id,
partialImage.metadata,
remoteId,
roomId,
status,
MessageType.image,
Expand All @@ -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<String, dynamic>? metadata,
PreviewData? previewData,
String? remoteId,
Status? status,
String? text,
int? updatedAt,
Expand All @@ -98,6 +103,7 @@ class ImageMessage extends Message {
...this.metadata ?? {},
...metadata,
},
remoteId: remoteId,
roomId: roomId,
size: size,
status: status ?? this.status,
Expand Down
2 changes: 2 additions & 0 deletions lib/src/messages/image_message.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion lib/src/messages/text_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class TextMessage extends Message {
required String id,
Map<String, dynamic>? metadata,
this.previewData,
String? remoteId,
String? roomId,
Status? status,
required this.text,
Expand All @@ -28,6 +29,7 @@ class TextMessage extends Message {
createdAt,
id,
metadata,
remoteId,
roomId,
status,
type ?? MessageType.text,
Expand All @@ -40,6 +42,7 @@ class TextMessage extends Message {
int? createdAt,
required String id,
required PartialText partialText,
String? remoteId,
String? roomId,
Status? status,
int? updatedAt,
Expand All @@ -50,6 +53,7 @@ class TextMessage extends Message {
createdAt,
id,
partialText.metadata,
remoteId,
roomId,
status,
MessageType.text,
Expand All @@ -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<String, dynamic>? metadata,
PreviewData? previewData,
String? remoteId,
Status? status,
String? text,
int? updatedAt,
Expand All @@ -89,6 +94,7 @@ class TextMessage extends Message {
...metadata,
},
previewData: previewData,
remoteId: remoteId,
roomId: roomId,
status: status ?? this.status,
text: text ?? this.text,
Expand Down
2 changes: 2 additions & 0 deletions lib/src/messages/text_message.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion lib/src/messages/unsupported_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class UnsupportedMessage extends Message {
int? createdAt,
required String id,
Map<String, dynamic>? metadata,
String? remoteId,
String? roomId,
Status? status,
MessageType? type,
Expand All @@ -28,6 +29,7 @@ class UnsupportedMessage extends Message {
createdAt,
id,
metadata,
remoteId,
roomId,
status,
type ?? MessageType.unsupported,
Expand All @@ -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<String, dynamic>? metadata,
PreviewData? previewData,
String? remoteId,
Status? status,
String? text,
int? updatedAt,
Expand All @@ -69,6 +72,7 @@ class UnsupportedMessage extends Message {
...this.metadata ?? {},
...metadata,
},
remoteId: remoteId,
roomId: roomId,
status: status ?? this.status,
updatedAt: updatedAt,
Expand Down
2 changes: 2 additions & 0 deletions lib/src/messages/unsupported_message.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit a402a8c

Please sign in to comment.