[Message, ChannelModel] Add merge helper functions for easier data change

This commit is contained in:
Sahil Kumar
2021-01-22 16:20:02 +05:30
parent 8f8eee0fc8
commit b292ab2a0e
3 changed files with 55 additions and 38 deletions
@@ -250,6 +250,38 @@ class Message {
deletedAt: deletedAt ?? this.deletedAt,
status: status ?? this.status,
);
/// Returns a new [Message] that is a combination of this message and the given
/// [other] message.
Message merge(Message other) {
if (other == null) return null;
return copyWith(
id: other.id,
text: other.text,
type: other.type,
attachments: other.attachments,
mentionedUsers: other.mentionedUsers,
reactionCounts: other.reactionCounts,
reactionScores: other.reactionScores,
latestReactions: other.latestReactions,
ownReactions: other.ownReactions,
parentId: other.parentId,
quotedMessage: other.quotedMessage,
quotedMessageId: other.quotedMessageId,
replyCount: other.replyCount,
threadParticipants: other.threadParticipants,
showInChannel: other.showInChannel,
command: other.command,
createdAt: other.createdAt,
silent: other.silent,
extraData: other.extraData,
user: other.user,
shadowed: other.shadowed,
updatedAt: other.updatedAt,
deletedAt: other.deletedAt,
status: other.status,
);
}
}
/// A translated message