Skip to content

Commit 9a50933

Browse files
authored
#5133 Fix broken email threading for draft messages (#5874)
* initial commit * remove console.log() * fix broken threading issue * revert previous changes * fix missing references value * pr reviews: correctly set references header * fix check redundancy
1 parent da96582 commit 9a50933

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

extension/chrome/elements/compose-modules/compose-render-module.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ export class ComposeRenderModule extends ViewModule<ComposeView> {
9898
const thread = await this.view.emailProvider.threadGet(this.view.threadId, 'metadata');
9999
const inReplyToMessage = thread.messages?.find(message => message.id === this.view.replyMsgId);
100100
if (inReplyToMessage) {
101-
this.view.replyParams.inReplyTo = inReplyToMessage.payload?.headers?.find(
102-
header => header.name === 'Message-Id' || header.name === 'Message-ID'
103-
)?.value;
101+
const msgId = inReplyToMessage.payload?.headers?.find(header => header.name === 'Message-Id' || header.name === 'Message-ID')?.value;
102+
const references = inReplyToMessage.payload?.headers?.find(header => header.name === 'References')?.value;
103+
this.setReplyHeaders(msgId, references);
104104
}
105105
this.view.replyParams.subject = `${this.responseMethod === 'reply' ? 'Re' : 'Fwd'}: ${this.view.replyParams.subject}`;
106106
if (this.view.useFullScreenSecureCompose) {
@@ -117,8 +117,7 @@ export class ComposeRenderModule extends ViewModule<ComposeView> {
117117
);
118118
if (this.view.quoteModule.messageToReplyOrForward) {
119119
const msgId = this.view.quoteModule.messageToReplyOrForward.headers['message-id'];
120-
this.view.sendBtnModule.additionalMsgHeaders['In-Reply-To'] = msgId;
121-
this.view.sendBtnModule.additionalMsgHeaders.References = this.view.quoteModule.messageToReplyOrForward.headers.references + ' ' + msgId;
120+
this.setReplyHeaders(msgId, this.view.quoteModule.messageToReplyOrForward.headers.references);
122121
if (this.view.replyPubkeyMismatch) {
123122
await this.renderReplyMsgAsReplyPubkeyMismatch();
124123
} else if (this.view.quoteModule.messageToReplyOrForward.isOnlySigned) {
@@ -273,6 +272,13 @@ export class ComposeRenderModule extends ViewModule<ComposeView> {
273272
}
274273
};
275274

275+
private setReplyHeaders = (msgId?: string, references?: string) => {
276+
if (msgId) {
277+
this.view.sendBtnModule.additionalMsgHeaders['In-Reply-To'] = msgId;
278+
this.view.sendBtnModule.additionalMsgHeaders.References = [references, msgId].filter(Boolean).join(' ');
279+
}
280+
};
281+
276282
private initComposeBoxStyles = () => {
277283
if (this.view.isReplyBox) {
278284
this.view.S.cached('body').addClass('reply_box');

0 commit comments

Comments
 (0)