updateDraft method
Updates RxChat.draft with the current values of the send field.
Implementation
void updateDraft() {
// [Attachment]s to persist in a [RxChat.draft].
final Iterable<MapEntry<GlobalKey, Attachment>> persisted;
// Only persist uploaded [Attachment]s on Web to minimize byte writing lags.
if (PlatformUtils.isWeb) {
persisted = send.attachments.where(
(e) => e.value is ImageAttachment || e.value is FileAttachment,
);
} else {
persisted = List.from(send.attachments, growable: false);
}
chat?.setDraft(
text: send.field.text.isEmpty ? null : ChatMessageText(send.field.text),
attachments: persisted.map((e) => e.value).toList(),
repliesTo: List.from(send.replied.map((e) => e.value), growable: false),
);
}