-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* issue 5747 initial refactor * removed dated comment * cleanup * added a generic folder * remove unused notifyMurdered parameter * added comment * upload debug artifacts * remove verbose google-mock listening logs
- Loading branch information
Showing
9 changed files
with
273 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
extension/js/content_scripts/webmail/generic/webmail-element-replacer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* ©️ 2016 - present FlowCrypt a.s. Limitations apply. Contact [email protected] */ | ||
|
||
import { ContentScriptWindow } from '../../../common/browser/browser-window'; | ||
import { notifyMurdered } from './setup-webmail-content-script'; | ||
|
||
export type IntervalFunction = { interval: number; handler: () => void }; | ||
|
||
export abstract class WebmailElementReplacer { | ||
private replacePgpElsInterval: number; | ||
|
||
public abstract getIntervalFunctions: () => IntervalFunction[]; | ||
public abstract setReplyBoxEditable: () => Promise<void>; | ||
public abstract reinsertReplyBox: (replyMsgId: string) => void; | ||
public abstract scrollToReplyBox: (replyMsgId: string) => void; | ||
public abstract scrollToCursorInReplyBox: (replyMsgId: string, cursorOffsetTop: number) => void; | ||
|
||
public runIntervalFunctionsPeriodically = () => { | ||
const intervalFunctions = this.getIntervalFunctions(); | ||
for (const intervalFunction of intervalFunctions) { | ||
intervalFunction.handler(); | ||
this.replacePgpElsInterval = (window as unknown as ContentScriptWindow).TrySetDestroyableInterval(() => { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
if (typeof (window as any).$ === 'function') { | ||
intervalFunction.handler(); | ||
} else { | ||
// firefox will unload jquery when extension is restarted or updated | ||
clearInterval(this.replacePgpElsInterval); | ||
notifyMurdered(); | ||
} | ||
}, intervalFunction.interval); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.