From fa343e076804ce5597b03201ff9533d84fe3e4e3 Mon Sep 17 00:00:00 2001 From: nesgarbo Date: Thu, 16 Apr 2026 12:55:59 +0200 Subject: [PATCH] fix: hide ICS attachments from email attachment list when invitation banner is shown MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When an email contains a calendar invitation, the raw .ics MIME parts (text/calendar, application/ics, application/icalendar) were showing up in the attachment list alongside the calendar invitation banner, which is confusing — the banner already provides the relevant UI. Filter those MIME types out of the displayed attachment list whenever the calendar invitation banner is active, reusing the existing isCalendarMimeType utility from lib/calendar-invitation.ts. --- components/email/email-viewer.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/email/email-viewer.tsx b/components/email/email-viewer.tsx index e5000d14..433b02b7 100644 --- a/components/email/email-viewer.tsx +++ b/components/email/email-viewer.tsx @@ -85,7 +85,7 @@ import { UnsubscribeBanner } from "./unsubscribe-banner"; import { CalendarInvitationBanner } from "./calendar-invitation-banner"; import { useTour } from "@/components/tour/tour-provider"; import { SmimePassphraseDialog } from "@/components/settings/smime-passphrase-dialog"; -import { findCalendarAttachment } from "@/lib/calendar-invitation"; +import { findCalendarAttachment, isCalendarMimeType } from "@/lib/calendar-invitation"; import { RecipientPopover } from "./recipient-popover"; import { isFilePreviewable } from "@/lib/file-preview"; import { SmimeStatusBanner } from "./smime-status-banner"; @@ -2084,11 +2084,15 @@ export function EmailViewer({ })); } + const hasCalInvitation = calendarInvitationParsingEnabled && !!email && !!findCalendarAttachment(email); const jmapAttachments = (email?.attachments ?? []) // Hide winmail.dat when we have successfully extracted TNEF content or attachments .filter(att => !(tnefHtml || tnefText || tnefAttachments.length > 0) || !isTnefAttachment(att.name, att.type)) // Hide message/rfc822 when we have unwrapped the embedded email .filter(att => !embeddedEmailUnwrapped || att.type !== 'message/rfc822') + // Hide calendar MIME parts (text/calendar, application/ics) when the invitation + // banner is shown — prevents raw ICS files appearing as spurious attachments. + .filter(att => !hasCalInvitation || !isCalendarMimeType(att.type)) .map((attachment, index) => ({ id: attachment.blobId || `${attachment.name || 'attachment'}-${index}`, name: attachment.name || null, @@ -2119,7 +2123,7 @@ export function EmailViewer({ })); return [...jmapAttachments, ...tnefExtracted, ...embeddedExtracted]; - }, [email?.attachments, smimeDecryptedAttachments, tnefHtml, tnefText, tnefAttachments, embeddedEmailUnwrapped, embeddedEmailAttachments]); + }, [email?.attachments, smimeDecryptedAttachments, tnefHtml, tnefText, tnefAttachments, embeddedEmailUnwrapped, embeddedEmailAttachments, calendarInvitationParsingEnabled]); // Generate email source for viewing const generateEmailSource = (email: Email): string => {