d14ff9d73c
Signed-off-by: dab246 <tdvu@linagora.com> (cherry picked from commit d4a95bfa305b198f5d3c369e3f49decb495b6fba)
30 lines
1004 B
Dart
30 lines
1004 B
Dart
|
|
import 'package:jmap_dart_client/jmap/account_id.dart';
|
|
import 'package:model/email/attachment.dart';
|
|
|
|
extension ListAttachmentExtension on List<Attachment> {
|
|
|
|
num totalSize() {
|
|
if (isNotEmpty) {
|
|
final currentListSize = map((attachment) => attachment.size?.value ?? 0).toList();
|
|
final totalSize = currentListSize.reduce((sum, size) => sum + size);
|
|
return totalSize;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
List<Attachment> get listAttachmentsDisplayedOutSide => where((attachment) => attachment.noCid() || !attachment.isInlined()).toList();
|
|
|
|
List<Attachment> get listAttachmentsDisplayedInContent => where((attachment) => attachment.hasCid()).toList();
|
|
|
|
Map<String, String> toMapCidImageDownloadUrl({
|
|
required AccountId accountId,
|
|
required String downloadUrl
|
|
}) {
|
|
final mapUrlDownloadCID = {
|
|
for (var attachment in listAttachmentsDisplayedInContent)
|
|
attachment.cid! : attachment.getDownloadUrl(downloadUrl, accountId)
|
|
};
|
|
return mapUrlDownloadCID;
|
|
}
|
|
} |