From 5d7f0528cdf255e653110ae727a0ce4a7a7c67f5 Mon Sep 17 00:00:00 2001 From: martgil Date: Fri, 29 Nov 2024 11:43:50 +0800 Subject: [PATCH] revert previous changes --- .../webmail/generic/webmail-element-replacer.ts | 2 +- .../webmail/gmail/gmail-element-replacer.ts | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/extension/js/content_scripts/webmail/generic/webmail-element-replacer.ts b/extension/js/content_scripts/webmail/generic/webmail-element-replacer.ts index e08b5c202c3..ed5fbf06606 100644 --- a/extension/js/content_scripts/webmail/generic/webmail-element-replacer.ts +++ b/extension/js/content_scripts/webmail/generic/webmail-element-replacer.ts @@ -9,7 +9,7 @@ export abstract class WebmailElementReplacer { private replacePgpElsInterval: number; public abstract getIntervalFunctions: () => IntervalFunction[]; - public abstract setReplyBoxEditable: (messageContainer?: JQuery) => Promise; + public abstract setReplyBoxEditable: () => Promise; public abstract reinsertReplyBox: (replyMsgId: string) => void; public abstract scrollToReplyBox: (replyMsgId: string) => void; public abstract scrollToCursorInReplyBox: (replyMsgId: string, cursorOffsetTop: number) => void; diff --git a/extension/js/content_scripts/webmail/gmail/gmail-element-replacer.ts b/extension/js/content_scripts/webmail/gmail/gmail-element-replacer.ts index 18e89cf1094..a691c7be657 100644 --- a/extension/js/content_scripts/webmail/gmail/gmail-element-replacer.ts +++ b/extension/js/content_scripts/webmail/gmail/gmail-element-replacer.ts @@ -85,10 +85,10 @@ export class GmailElementReplacer extends WebmailElementReplacer { ]; }; - public setReplyBoxEditable = async (messageContainer?: JQuery) => { + public setReplyBoxEditable = async () => { const replyContainerIframe = $('.reply_message_iframe_container > iframe').last(); - if (replyContainerIframe.length && messageContainer) { - $(replyContainerIframe).replaceWith(this.factory.embeddedReply(this.getLastMsgReplyParams(messageContainer), true)); // xss-safe-value + if (replyContainerIframe.length) { + $(replyContainerIframe).replaceWith(this.factory.embeddedReply(this.getLastMsgReplyParams(this.getConvoRootEl(replyContainerIframe[0])), true)); // xss-safe-value } else { await this.replaceStandardReplyBox(undefined, true); } @@ -351,10 +351,10 @@ export class GmailElementReplacer extends WebmailElementReplacer { return; } // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const messageContainer: JQuery = $(btn.closest('.h7')!); + const messageContainer = $(btn.closest('.h7')!); if (messageContainer.is(':last-child')) { if (this.isEncrypted()) { - await this.setReplyBoxEditable(messageContainer); + await this.setReplyBoxEditable(); } else { await this.replaceStandardReplyBox(undefined, true); } @@ -589,10 +589,8 @@ export class GmailElementReplacer extends WebmailElementReplacer { return from ? Str.parseEmail(from) : undefined; }; - private getLastMsgReplyParams = (convoRootEl: JQuery): FactoryReplyParams => { - const msgIdElement = $(convoRootEl).find('[data-legacy-message-id], [data-message-id]'); - const msgId = msgIdElement.attr('data-legacy-message-id') || msgIdElement.attr('data-message-id'); - return { replyMsgId: msgId }; + private getLastMsgReplyParams = (convoRootEl: JQuery): FactoryReplyParams => { + return { replyMsgId: this.determineMsgId($(convoRootEl).find(this.sel.msgInner).last()) }; }; private getConvoRootEl = (anyInnerElement: HTMLElement) => {