style: Apply team linter in stream chat persistence (#331)

* lint(persistence): Apply team linter

Signed-off-by: Sahil Kumar <[email protected]>

* style: flutter format

Signed-off-by: Sahil Kumar <[email protected]>
This commit is contained in:
Sahil Kumar
2021-03-15 10:23:44 +01:00
committed by GitHub
parent a8443a98b0
commit 8ec54f3834
30 changed files with 813 additions and 772 deletions
@@ -12,70 +12,66 @@ extension MessageEntityX on MessageEntity {
List<Reaction> latestReactions,
List<Reaction> ownReactions,
Message quotedMessage,
}) {
return Message(
shadowed: shadowed,
latestReactions: latestReactions,
ownReactions: ownReactions,
attachments: attachments?.map((it) {
final json = jsonDecode(it);
return Attachment.fromData(json);
})?.toList(),
createdAt: createdAt,
extraData: extraData,
updatedAt: updatedAt,
id: id,
type: type,
status: status,
command: command,
parentId: parentId,
quotedMessageId: quotedMessageId,
quotedMessage: quotedMessage,
reactionCounts: reactionCounts,
reactionScores: reactionScores,
replyCount: replyCount,
showInChannel: showInChannel,
text: messageText,
user: user,
deletedAt: deletedAt,
pinned: pinned,
pinnedAt: pinnedAt,
pinExpires: pinExpires,
pinnedBy: pinnedBy,
);
}
}) =>
Message(
shadowed: shadowed,
latestReactions: latestReactions,
ownReactions: ownReactions,
attachments: attachments?.map((it) {
final json = jsonDecode(it);
return Attachment.fromData(json);
})?.toList(),
createdAt: createdAt,
extraData: extraData,
updatedAt: updatedAt,
id: id,
type: type,
status: status,
command: command,
parentId: parentId,
quotedMessageId: quotedMessageId,
quotedMessage: quotedMessage,
reactionCounts: reactionCounts,
reactionScores: reactionScores,
replyCount: replyCount,
showInChannel: showInChannel,
text: messageText,
user: user,
deletedAt: deletedAt,
pinned: pinned,
pinnedAt: pinnedAt,
pinExpires: pinExpires,
pinnedBy: pinnedBy,
);
}
/// Useful mapping functions for [Message]
extension MessageX on Message {
/// Maps a [Message] into [MessageEntity]
MessageEntity toEntity({String cid}) {
return MessageEntity(
id: id,
attachments: attachments?.map((it) {
return jsonEncode(it.toData());
})?.toList(),
channelCid: cid,
type: type,
parentId: parentId,
quotedMessageId: quotedMessageId,
command: command,
createdAt: createdAt,
shadowed: shadowed,
showInChannel: showInChannel,
replyCount: replyCount,
reactionScores: reactionScores,
reactionCounts: reactionCounts,
status: status,
updatedAt: updatedAt,
extraData: extraData,
userId: user?.id,
deletedAt: deletedAt,
messageText: text,
pinned: pinned,
pinnedAt: pinnedAt,
pinExpires: pinExpires,
pinnedByUserId: pinnedBy?.id,
);
}
MessageEntity toEntity({String cid}) => MessageEntity(
id: id,
attachments:
attachments?.map((it) => jsonEncode(it.toData()))?.toList(),
channelCid: cid,
type: type,
parentId: parentId,
quotedMessageId: quotedMessageId,
command: command,
createdAt: createdAt,
shadowed: shadowed,
showInChannel: showInChannel,
replyCount: replyCount,
reactionScores: reactionScores,
reactionCounts: reactionCounts,
status: status,
updatedAt: updatedAt,
extraData: extraData,
userId: user?.id,
deletedAt: deletedAt,
messageText: text,
pinned: pinned,
pinnedAt: pinnedAt,
pinExpires: pinExpires,
pinnedByUserId: pinnedBy?.id,
);
}