From 0e2ea6a6353d28c4eb0fdca9f2da40c680c2b04e Mon Sep 17 00:00:00 2001 From: dab246 Date: Mon, 10 Mar 2025 15:16:11 +0700 Subject: [PATCH] TF-3514 Perform sequential upload on base64 image when converting to cid Signed-off-by: dab246 --- .../email/data/local/html_analyzer.dart | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/lib/features/email/data/local/html_analyzer.dart b/lib/features/email/data/local/html_analyzer.dart index cac60a928..fdb1d14d1 100644 --- a/lib/features/email/data/local/html_analyzer.dart +++ b/lib/features/email/data/local/html_analyzer.dart @@ -140,7 +140,6 @@ class HtmlAnalyzer { } final Set inlineAttachmentsSet = {}; - final List> asyncTasks = []; for (final imgTag in listImgTag) { final attributes = imgTag.attributes; @@ -166,29 +165,25 @@ class HtmlAnalyzer { ? idImg!.substring(cidPrefixKey.length) : _uuid.v1(); - asyncTasks.add(_retrieveAttachmentFromUpload( + final attachmentRecord = await _retrieveAttachmentFromUpload( taskId: taskId, uploadUri: uploadUri, base64ImageTag: imageSrc!, - ).then((attachmentRecord) { - if (attachmentRecord == null) return; + ); - final newInlineAttachment = attachmentRecord.$1.toAttachmentWithDisposition( - disposition: ContentDisposition.inline, - cid: attachmentRecord.$2, - ); + if (attachmentRecord == null) continue; - final newCid = newInlineAttachment.cid!; - inlineAttachments[newCid] = newInlineAttachment; - attributes['src'] = '$cidPrefixKey$newCid'; - attributes.remove('id'); + final newInlineAttachment = attachmentRecord.$1.toAttachmentWithDisposition( + disposition: ContentDisposition.inline, + cid: attachmentRecord.$2, + ); - inlineAttachmentsSet.add(newInlineAttachment.toEmailBodyPart(charset: Constant.base64Charset)); - })); - } + final newCid = newInlineAttachment.cid!; + inlineAttachments[newCid] = newInlineAttachment; + attributes['src'] = '$cidPrefixKey$newCid'; + attributes.remove('id'); - if (asyncTasks.isNotEmpty) { - await Future.wait(asyncTasks); + inlineAttachmentsSet.add(newInlineAttachment.toEmailBodyPart(charset: Constant.base64Charset)); } return Tuple2(document.body?.innerHtml ?? emailContent, inlineAttachmentsSet);