Skip to content

Commit 72803ff

Browse files
committed
add checking before adding the button to avoid unncessary button
1 parent bd60c6d commit 72803ff

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

extension/js/content_scripts/webmail/gmail/gmail-element-replacer.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,9 @@ export class GmailElementReplacer extends WebmailElementReplacer {
151151
$(document).on('click', 'div.aHU.hx', event => {
152152
const $actionsBtn = $(event.currentTarget).find(this.sel.msgActionsBtn);
153153
if ($actionsBtn.length && !$('.action_menu_message_button').length) {
154-
this.addMenuButton('reply', '#r');
155-
this.addMenuButton('forward', '#r3');
154+
this.addMenuButton('a_reply', '#r');
155+
this.addMenuButton('a_reply_all', '#r2');
156+
this.addMenuButton('a_forward', '#r3');
156157
}
157158
});
158159
};
@@ -292,19 +293,12 @@ export class GmailElementReplacer extends WebmailElementReplacer {
292293

293294
private addMenuButton = (replyOption: ReplyOption, selector: string) => {
294295
const gmailActionsMenuContainer = $(this.sel.msgActionsMenu).find(selector);
295-
const button = $(this.factory.actionsMenuBtn(replyOption)).insertAfter(gmailActionsMenuContainer); // xss-safe-factory
296-
button.on(
297-
'click',
298-
Ui.event.handle((el, ev: JQuery.Event) => this.actionActivateSecureReplyHandler(el, ev))
299-
);
300-
};
301-
302-
private replaceActionsMenu = () => {
303-
if ($('.action_menu_message_button').length <= 0) {
304-
this.addMenuButton('a_reply', '#r');
305-
// * when adding the reply_all button, check if #r2, the placeholder for reply_all, is visible
306-
// * otherwise, it's not wise adding reply_all for single recipient emails
307-
this.addMenuButton('a_forward', '#r3');
296+
if ($(selector).css('display') === 'block') {
297+
const button = $(this.factory.actionsMenuBtn(replyOption)).insertAfter(gmailActionsMenuContainer); // xss-safe-factory
298+
button.on(
299+
'click',
300+
Ui.event.handle((el, ev: JQuery.Event) => this.actionActivateSecureReplyHandler(el, ev))
301+
);
308302
}
309303
};
310304

0 commit comments

Comments
 (0)