toModel method
Constructs a new list of Attachments from this GetAttachments$Query$ChatItem.
Implementation
List<Attachment> toModel() {
final List<Attachment> attachments = [];
if (node.$$typename == 'ChatMessage') {
var message = node as GetAttachments$Query$ChatItem$Node$ChatMessage;
attachments.addAll(message.attachments.map((e) => e.toModel()));
if (message.repliesTo.isNotEmpty) {
for (var r in message.repliesTo) {
if (r.original?.node.$$typename == 'ChatMessage') {
var replied =
r.original?.node
as GetAttachments$Query$ChatItem$Node$ChatMessage$RepliesTo$Original$Node$ChatMessage;
attachments.addAll(replied.attachments.map((e) => e.toModel()));
}
}
}
} else if (node.$$typename == 'ChatForward') {
var message = node as GetAttachments$Query$ChatItem$Node$ChatForward;
if (message.quote.$$typename == 'ChatMessageQuote') {
var quote =
message.quote
as GetAttachments$Query$ChatItem$Node$ChatForward$Quote$ChatMessageQuote;
attachments.addAll(quote.attachments.map((e) => e.toModel()));
}
}
return attachments;
}