summaryrefslogtreecommitdiff
path: root/source/libs/features.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'source/libs/features.tsx')
-rw-r--r--source/libs/features.tsx14
1 files changed, 12 insertions, 2 deletions
diff --git a/source/libs/features.tsx b/source/libs/features.tsx
index cc8f718f..0914b60a 100644
--- a/source/libs/features.tsx
+++ b/source/libs/features.tsx
@@ -43,13 +43,22 @@ export interface FeatureDetails {
* Alternatively, use `onAjaxedPagesRaw` if your callback needs to be called at every page
* change (e.g. to "unmount" a feature / listener) regardless of *newness* of the page.
*/
-async function onAjaxedPagesRaw(callback: () => void): Promise<void> {
- await onDomReady;
+function onAjaxedPagesRaw(callback: () => void): void {
document.addEventListener('pjax:end', callback);
callback();
}
function onAjaxedPages(callback: () => void): void {
+ onAjaxedPagesRaw(async () => {
+ await onDomReady;
+ if (!select.exists('has-rgh')) {
+ callback();
+ }
+ });
+}
+
+// Like onAjaxedPages but doesn't wait for `dom-ready`
+function nowAndOnAjaxedPages(callback: () => void): void {
onAjaxedPagesRaw(() => {
if (!select.exists('has-rgh')) {
callback();
@@ -186,6 +195,7 @@ export default {
onNewComments,
onFileListUpdate,
onAjaxedPages,
+ nowAndOnAjaxedPages,
onAjaxedPagesRaw,
// Loading filters