Fix infinite scrolling for activities

This fixes the error:

Uncaught TypeError: activitiesComponent.loadNextPage is not a function
    at constructor.reachNextPeak (sidebar.js:63)
    at constructor.BlazeComponent.callFirstWith (peerlibrary_blaze-components.js?hash=4049f7e3116e3d9e865392b9546e70dc479b9add:660)
    at constructor.scroll (infiniteScrolling.js:28)
    at peerlibrary_blaze-components.js?hash=4049f7e3116e3d9e865392b9546e70dc479b9add:469
    at Object.Blaze._withCurrentView (view.js:533)
    at peerlibrary_blaze-components.js?hash=4049f7e3116e3d9e865392b9546e70dc479b9add:468
    at Template._withTemplateInstanceFunc (template.js:490)
    at Blaze.View.eventMap.<computed> (peerlibrary_blaze-components.js?hash=4049f7e3116e3d9e865392b9546e70dc479b9add:467)
    at view.js:879
    at Object.Blaze._withCurrentView (view.js:533)
This commit is contained in:
Marc Hartmayer 2020-06-10 23:50:48 +02:00
parent 2d4f29cb5a
commit 06cacd7a5a

View file

@ -7,7 +7,7 @@ BlazeComponent.extendComponent({
// XXX Should we use ReactiveNumber?
this.page = new ReactiveVar(1);
this.loadNextPageLocked = false;
const sidebar = this.parentComponent(); // XXX for some reason not working
const sidebar = Sidebar;
sidebar.callFirstWith(null, 'resetNextPeak');
this.autorun(() => {
let mode = this.data().mode;
@ -43,16 +43,15 @@ BlazeComponent.extendComponent({
});
});
},
}).register('activities');
BlazeComponent.extendComponent({
loadNextPage() {
if (this.loadNextPageLocked === false) {
this.page.set(this.page.get() + 1);
this.loadNextPageLocked = true;
}
},
}).register('activities');
BlazeComponent.extendComponent({
checkItem() {
const checkItemId = this.currentData().activity.checklistItemId;
const checkItem = ChecklistItems.findOne({ _id: checkItemId });