TF-2510 Show PDF icon if `(mimetype == pdf || (mimetype == application/octet-stream && file.extension == pdf)

Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
dab246
2024-01-26 08:55:36 +07:00
committed by Dat H. Pham
parent e368062d9e
commit 49054d6a71
2 changed files with 93 additions and 0 deletions
@@ -7,6 +7,10 @@ extension AttachmentExtension on Attachment {
String getIcon(ImagePaths imagePaths) {
final mediaType = type;
log('AttachmentExtension::getIcon(): mediaType: $mediaType');
if (isDisplayedPDFIcon) {
return imagePaths.icFilePdf;
}
if (mediaType == null) {
return imagePaths.icFileEPup;
}
@@ -25,4 +29,7 @@ extension AttachmentExtension on Attachment {
}
return imagePaths.icFileEPup;
}
bool get isDisplayedPDFIcon => type?.mimeType == 'application/pdf' ||
(type?.mimeType == 'application/octet-stream' && name?.endsWith('.pdf') == true);
}