Skip to content

Commit ae3e7bc

Browse files
committed
fix missing icon for generic filetype
1 parent 7eae082 commit ae3e7bc

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

extension/js/content_scripts/webmail/thunderbird/thunderbird-element-replacer.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,16 @@ export class ThunderbirdElementReplacer extends WebmailElementReplacer {
143143
};
144144

145145
private generatePgpAttachmentTemplate = (originalFilename: string, attachmentData: Buf) => {
146-
const uiFileExtensions = ['excel', 'word', 'png', 'jpg', 'generic'];
147146
const attachmentHtmlRoot = $('<div>').addClass('thunderbird_attachment_root');
148147
const attachmentFileTypeIcon = $('<img>').addClass('thunderbird_attachment_icon');
149148
const decryptedFileName = originalFilename.replace(/\.(pgp|gpg|asc)$/i, '');
150-
uiFileExtensions.some(fileExtension => {
151-
if (decryptedFileName.endsWith(fileExtension)) {
152-
attachmentFileTypeIcon.attr('src', messenger.runtime.getURL(`/img/fileformat/${fileExtension}.png`));
153-
}
154-
});
149+
const uiFileExtensions = ['excel', 'word', 'png', 'jpg'];
150+
const matchedExtension = uiFileExtensions.find(fileExtension => decryptedFileName.endsWith(fileExtension));
151+
if (matchedExtension) {
152+
attachmentFileTypeIcon.attr('src', messenger.runtime.getURL(`/img/fileformat/${matchedExtension}.png`));
153+
} else {
154+
attachmentFileTypeIcon.attr('src', messenger.runtime.getURL(`/img/fileformat/generic.png`));
155+
}
155156
const attachmentFilename = $('<div>').addClass('thunderbird_attachment_name').text(originalFilename);
156157
const attachmentDownloadBtn = $('<div>')
157158
.addClass('thunderbird_attachment_download')

0 commit comments

Comments
 (0)