From fdfd0a6454bdecdf30945fb5a0119648761e8413 Mon Sep 17 00:00:00 2001 From: Jiiks Date: Thu, 8 Mar 2018 17:37:38 +0200 Subject: [PATCH] add loading more mutation callback --- client/src/index.js | 1 + client/src/ui/automanip.js | 10 ++++++++++ client/src/ui/dom.js | 1 + 3 files changed, 12 insertions(+) diff --git a/client/src/index.js b/client/src/index.js index 3a292197..742bde01 100644 --- a/client/src/index.js +++ b/client/src/index.js @@ -30,6 +30,7 @@ class BetterDiscord { window.bdmodals = Modals; window.bdlogs = Logger; window.emotes = EmoteModule; + window.dom = DOM; EmoteModule.observe(); DOM.injectStyle(BdCss, 'bdmain'); Events.on('global-ready', this.globalReady.bind(this)); diff --git a/client/src/ui/automanip.js b/client/src/ui/automanip.js index d1650fe0..d7629043 100644 --- a/client/src/ui/automanip.js +++ b/client/src/ui/automanip.js @@ -74,6 +74,16 @@ export default class { const markup = e.element.querySelector('.markup:not(.mutable)'); if (markup) this.injectMarkup(markup, this.cloneMarkup(markup), false); }); + + const filter = function (mutation) { + return mutation.removedNodes && mutation.removedNodes.length && mutation.removedNodes[0].className && mutation.removedNodes[0].className.includes('loading-more'); + } + + DOM.observer.subscribe('loading-more-manip', filter, mutation => { + Events.emit('ui:loadedmore'); + this.setIds(); + this.makeMutable(); + }); } getEts(node) { diff --git a/client/src/ui/dom.js b/client/src/ui/dom.js index 55a0d179..67ca8bbe 100644 --- a/client/src/ui/dom.js +++ b/client/src/ui/dom.js @@ -37,6 +37,7 @@ class DOMObserver { this.subscribe = this.subscribe.bind(this); this.observerCallback = this.observerCallback.bind(this); this.observer = new MutationObserver(this.observerCallback); + this.observe(); } observerCallback(mutations) {