fix: implement draft editing functionality across email components and add localization keys

This commit is contained in:
Linus Rath
2026-03-18 18:39:46 +01:00
parent 6457b27125
commit bb72ac92ae
12 changed files with 156 additions and 19 deletions
+31
View File
@@ -468,6 +468,33 @@ export default function Home() {
if (isMobile) setActiveView('viewer');
};
const handleEditDraft = (email?: Email) => {
const draft = email || selectedEmail;
if (!draft) return;
const bodyText = draft.bodyValues
? Object.values(draft.bodyValues).map(v => v.value).join('\n')
: '';
const htmlBody = draft.htmlBody?.[0]?.partId && draft.bodyValues?.[draft.htmlBody[0].partId]
? draft.bodyValues[draft.htmlBody[0].partId].value
: undefined;
setPendingDraft({
to: draft.to?.map(a => a.email).filter(Boolean).join(', ') || '',
cc: draft.cc?.map(a => a.email).filter(Boolean).join(', ') || '',
bcc: draft.bcc?.map(a => a.email).filter(Boolean).join(', ') || '',
subject: draft.subject || '',
body: htmlBody || bodyText,
showCc: (draft.cc?.length || 0) > 0,
showBcc: (draft.bcc?.length || 0) > 0,
selectedIdentityId: null,
subAddressTag: '',
mode: 'compose',
draftId: draft.id,
});
setComposerMode('compose');
setShowComposer(true);
if (isMobile) setActiveView('viewer');
};
const handleReplyAll = () => {
setComposerMode('replyAll');
setShowComposer(true);
@@ -1370,6 +1397,9 @@ export default function Home() {
selectEmail(email);
await handleUndoSpam();
}}
onEditDraft={(email) => {
handleEditDraft(email);
}}
className="flex-1 min-h-0"
/>
</ErrorBoundary>
@@ -1543,6 +1573,7 @@ export default function Home() {
onNavigateNext={handleNavigateNext}
onNavigatePrev={handleNavigatePrev}
onShowShortcuts={() => setShowShortcutsModal(true)}
onEditDraft={handleEditDraft}
currentUserEmail={client?.["username"]}
currentUserName={client?.["username"]?.split("@")[0]}
currentMailboxRole={mailboxes.find(m => m.id === selectedMailbox)?.role}