8eed49fd73
(cherry picked from commit f5470c130744242195b265a0ea4aad044ad8e740)
36 lines
1.1 KiB
Dart
36 lines
1.1 KiB
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 {
|
|
return where((attachment) => attachment.disposition == ContentDisposition.attachment || attachment.noCid())
|
|
.toList();
|
|
}
|
|
|
|
List<Attachment> get listAttachmentsDisplayedInContent {
|
|
return 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;
|
|
}
|
|
} |