downloadAttachment method
Implementation
Future<void> downloadAttachment(String attachmentId) async {
downloadingAttachments.add(attachmentId);
update();
try {
Attachment? attachment = attachments.firstWhereOrNull(
(attachment) => attachment.id == attachmentId,
);
if (attachment == null) {
await Future.delayed(const Duration(seconds: 3));
attachment = attachments.firstWhereOrNull(
(attachment) => attachment.id == attachmentId,
);
}
if (attachment == null) return;
await AttachmentService.downloadAttachment(attachment);
downloadingAttachments.remove(attachmentId);
update();
} catch (e) {
downloadingAttachments.remove(attachmentId);
update();
}
}