Skip to content

Commit

Permalink
Move replied messages to partial ones
Browse files Browse the repository at this point in the history
  • Loading branch information
demchenkoalex committed Jun 12, 2022
1 parent a941265 commit 0b985bb
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 8 deletions.
7 changes: 5 additions & 2 deletions lib/src/messages/custom_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,15 @@ abstract class CustomMessage extends Message {
required super.id,
required PartialCustom partialCustom,
super.remoteId,
super.repliedMessage,
super.roomId,
super.showStatus,
super.status,
super.updatedAt,
}) : super(metadata: partialCustom.metadata, type: MessageType.custom);
}) : super(
metadata: partialCustom.metadata,
repliedMessage: partialCustom.repliedMessage,
type: MessageType.custom,
);

/// Creates a custom message from a map (decoded JSON).
factory CustomMessage.fromJson(Map<String, dynamic> json) =>
Expand Down
7 changes: 5 additions & 2 deletions lib/src/messages/file_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ abstract class FileMessage extends Message {
this.isLoading,
required PartialFile partialFile,
super.remoteId,
super.repliedMessage,
super.roomId,
super.showStatus,
super.status,
Expand All @@ -67,7 +66,11 @@ abstract class FileMessage extends Message {
name = partialFile.name,
size = partialFile.size,
uri = partialFile.uri,
super(metadata: partialFile.metadata, type: MessageType.file);
super(
metadata: partialFile.metadata,
repliedMessage: partialFile.repliedMessage,
type: MessageType.file,
);

/// Creates a file message from a map (decoded JSON).
factory FileMessage.fromJson(Map<String, dynamic> json) =>
Expand Down
7 changes: 5 additions & 2 deletions lib/src/messages/image_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ abstract class ImageMessage extends Message {
required super.id,
required PartialImage partialImage,
super.remoteId,
super.repliedMessage,
super.roomId,
super.showStatus,
super.status,
Expand All @@ -67,7 +66,11 @@ abstract class ImageMessage extends Message {
size = partialImage.size,
uri = partialImage.uri,
width = partialImage.width,
super(metadata: partialImage.metadata, type: MessageType.image);
super(
metadata: partialImage.metadata,
repliedMessage: partialImage.repliedMessage,
type: MessageType.image,
);

/// Creates an image message from a map (decoded JSON).
factory ImageMessage.fromJson(Map<String, dynamic> json) =>
Expand Down
5 changes: 5 additions & 0 deletions lib/src/messages/partial_custom.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';

import '../message.dart';
import 'custom_message.dart';

part 'partial_custom.g.dart';
Expand All @@ -15,6 +16,7 @@ class PartialCustom {
/// message from a partial one.
const PartialCustom({
this.metadata,
this.repliedMessage,
});

/// Creates a partial custom message from a map (decoded JSON).
Expand All @@ -26,4 +28,7 @@ class PartialCustom {

/// Additional custom metadata or attributes related to the message
final Map<String, dynamic>? metadata;

/// Message that is being replied to with the current message
final Message? repliedMessage;
}
4 changes: 4 additions & 0 deletions lib/src/messages/partial_custom.g.dart

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

5 changes: 5 additions & 0 deletions lib/src/messages/partial_file.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';

import '../message.dart';
import 'file_message.dart';

part 'partial_file.g.dart';
Expand All @@ -17,6 +18,7 @@ class PartialFile {
this.metadata,
this.mimeType,
required this.name,
this.repliedMessage,
required this.size,
required this.uri,
});
Expand All @@ -37,6 +39,9 @@ class PartialFile {
/// The name of the file
final String name;

/// Message that is being replied to with the current message
final Message? repliedMessage;

/// Size of the file in bytes
final num size;

Expand Down
4 changes: 4 additions & 0 deletions lib/src/messages/partial_file.g.dart

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

5 changes: 5 additions & 0 deletions lib/src/messages/partial_image.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';

import '../message.dart';
import 'image_message.dart';

part 'partial_image.g.dart';
Expand All @@ -17,6 +18,7 @@ class PartialImage {
this.height,
this.metadata,
required this.name,
this.repliedMessage,
required this.size,
required this.uri,
this.width,
Expand All @@ -38,6 +40,9 @@ class PartialImage {
/// The name of the image
final String name;

/// Message that is being replied to with the current message
final Message? repliedMessage;

/// Size of the image in bytes
final num size;

Expand Down
4 changes: 4 additions & 0 deletions lib/src/messages/partial_image.g.dart

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

5 changes: 5 additions & 0 deletions lib/src/messages/partial_text.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';

import '../message.dart';
import '../preview_data.dart' show PreviewData;
import 'text_message.dart';

Expand All @@ -17,6 +18,7 @@ class PartialText {
const PartialText({
this.metadata,
this.previewData,
this.repliedMessage,
required this.text,
});

Expand All @@ -33,6 +35,9 @@ class PartialText {
/// See [PreviewData]
final PreviewData? previewData;

/// Message that is being replied to with the current message
final Message? repliedMessage;

/// User's message
final String text;
}
4 changes: 4 additions & 0 deletions lib/src/messages/partial_text.g.dart

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

7 changes: 5 additions & 2 deletions lib/src/messages/text_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,17 @@ abstract class TextMessage extends Message {
required super.id,
required PartialText partialText,
super.remoteId,
super.repliedMessage,
super.roomId,
super.showStatus,
super.status,
super.updatedAt,
}) : previewData = partialText.previewData,
text = partialText.text,
super(metadata: partialText.metadata, type: MessageType.text);
super(
metadata: partialText.metadata,
repliedMessage: partialText.repliedMessage,
type: MessageType.text,
);

/// Creates a text message from a map (decoded JSON).
factory TextMessage.fromJson(Map<String, dynamic> json) =>
Expand Down

0 comments on commit 0b985bb

Please sign in to comment.