fix: honor the user's filename template for forward-as-attachment
buildForwardAsAttachmentPayload called emailExportFilename(email) with no options, always using the default naming template regardless of the user's configured emailDownloadTemplate (and space/case/diacritics transforms) - the same settings the neighboring "Export as .eml" action already respects. That could produce inconsistent .eml filenames between the two actions for the same message. Accept an optional EmailFilenameOptions parameter and pass it through. handleForwardAsAttachment now reads the same settings email-viewer.tsx's emailFilenameOptions useMemo does, via useSettingsStore.getState() (a one-off read inside an event handler, matching this file's existing pattern, rather than a new reactive subscription). Add a unit test covering a custom template. Caught by GitHub Copilot's automated PR review.
This commit is contained in:
@@ -45,4 +45,14 @@ describe('buildForwardAsAttachmentPayload', () => {
|
||||
const payload = buildForwardAsAttachmentPayload(email, 'Fwd:');
|
||||
expect(payload?.subject).toBe('Fwd: already forwarded once');
|
||||
});
|
||||
|
||||
it('honors a custom filename template, matching "Export as .eml" naming instead of always using the default', () => {
|
||||
const email = makeEmail({ subject: 'Missed spam example' });
|
||||
const payload = buildForwardAsAttachmentPayload(email, 'Fwd:', {
|
||||
template: 'custom-{subject}',
|
||||
lowercase: true,
|
||||
spaceReplacement: 'dash',
|
||||
});
|
||||
expect(payload?.attachment.name).toBe('custom-missed-spam-example.eml');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user