Skip to content

Commit 6feb36e

Browse files
committed
wip: add retryInterval whenever element is not yet rendered
1 parent daeddbd commit 6feb36e

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export abstract class WebmailElementReplacer {
1414
public abstract reinsertReplyBox: (replyMsgId: string) => void;
1515
public abstract scrollToReplyBox: (replyMsgId: string) => void;
1616
public abstract scrollToCursorInReplyBox: (replyMsgId: string, cursorOffsetTop: number) => void;
17+
public abstract addSecureActionsToMessageMenu: () => void;
1718

1819
public runIntervalFunctionsPeriodically = () => {
1920
const intervalFunctions = this.getIntervalFunctions();

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

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,24 @@ export class GmailElementReplacer extends WebmailElementReplacer {
148148
}
149149
};
150150

151+
public addSecureActionsToMessageMenu = () => {
152+
const retryInterval = 100;
153+
const addButtons = () => {
154+
if (!$(this.sel.msgActionsBtn).length) {
155+
Catch.setHandledTimeout(addButtons, retryInterval);
156+
} else {
157+
$(document).on('click', 'div.aHU.hx', () => {
158+
if (!$('.action_menu_message_button').length) {
159+
this.addMenuButton('a_reply', '#r');
160+
this.addMenuButton('a_reply_all', '#r2');
161+
this.addMenuButton('a_forward', '#r3');
162+
}
163+
});
164+
}
165+
};
166+
addButtons();
167+
};
168+
151169
private everything = () => {
152170
this.replaceArmoredBlocks().catch(Catch.reportErr);
153171
this.replaceAttachments().catch(Catch.reportErr);
@@ -156,7 +174,6 @@ export class GmailElementReplacer extends WebmailElementReplacer {
156174
this.replaceStandardReplyBox().catch(Catch.reportErr);
157175
this.evaluateStandardComposeRecipients().catch(Catch.reportErr);
158176
this.addSettingsBtn();
159-
this.addSecureActionsToMessageMenu();
160177
this.renderLocalDrafts().catch(Catch.reportErr);
161178
};
162179

@@ -878,18 +895,6 @@ export class GmailElementReplacer extends WebmailElementReplacer {
878895
}
879896
};
880897

881-
private addSecureActionsToMessageMenu = () => {
882-
$(this.sel.msgActionsBtn)
883-
.off('click')
884-
.on('click', () => {
885-
if (!$('.action_menu_message_button').length) {
886-
this.addMenuButton('a_reply', '#r');
887-
this.addMenuButton('a_reply_all', '#r2');
888-
this.addMenuButton('a_forward', '#r3');
889-
}
890-
});
891-
};
892-
893898
private renderLocalDrafts = async () => {
894899
if (window.location.hash === '#drafts') {
895900
const storage = await GlobalStore.get(['local_drafts']);

extension/js/content_scripts/webmail/gmail/gmail-webmail-startup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export class GmailWebmailStartup {
4545
const messageRenderer = await MessageRenderer.newInstance(acctEmail, new Gmail(acctEmail), relayManager, factory);
4646
this.replacer = new GmailElementReplacer(factory, clientConfiguration, acctEmail, messageRenderer, injector, notifications, relayManager);
4747
await notifications.showInitial(acctEmail);
48+
this.replacer.addSecureActionsToMessageMenu();
4849
this.replacer.runIntervalFunctionsPeriodically();
4950
};
5051

0 commit comments

Comments
 (0)