add loading more mutation callback

This commit is contained in:
Jiiks 2018-03-08 17:37:38 +02:00
parent 88b46bc359
commit fdfd0a6454
3 changed files with 12 additions and 0 deletions

View File

@ -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));

View File

@ -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) {

View File

@ -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) {