mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 05:34:28 +08:00
DEV: Triggering "saw" on every element seems pointless
We don't seem to wire this up to any listeners, so why waste time doing all this work?
This commit is contained in:
parent
28e9f54e2f
commit
091d6dc9fc
|
@ -38,9 +38,7 @@ const DiscoveryTopicsListComponent = Component.extend(UrlRefresh, LoadMore, {
|
||||||
Discourse.updateContextCount(0);
|
Discourse.updateContextCount(0);
|
||||||
this.model.loadMore().then(hasMoreResults => {
|
this.model.loadMore().then(hasMoreResults => {
|
||||||
schedule("afterRender", () => this.saveScrollPosition());
|
schedule("afterRender", () => this.saveScrollPosition());
|
||||||
if (!hasMoreResults) {
|
if (hasMoreResults && $(window).height() >= $(document).height()) {
|
||||||
this.eyeline.flushRest();
|
|
||||||
} else if ($(window).height() >= $(document).height()) {
|
|
||||||
this.send("loadMore");
|
this.send("loadMore");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -110,10 +110,7 @@ export default Component.extend(LoadMore, {
|
||||||
|
|
||||||
this.set("loading", true);
|
this.set("loading", true);
|
||||||
const stream = this.stream;
|
const stream = this.stream;
|
||||||
stream.findItems().then(() => {
|
stream.findItems().then(() => this.set("loading", false));
|
||||||
this.set("loading", false);
|
|
||||||
this.eyeline.flushRest();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -78,7 +78,6 @@ Eyeline.prototype.update = function() {
|
||||||
|
|
||||||
// If you hit the bottom we mark all the elements as seen. Otherwise, just the first one
|
// If you hit the bottom we mark all the elements as seen. Otherwise, just the first one
|
||||||
if (!atBottom) {
|
if (!atBottom) {
|
||||||
appEvents.trigger("saw", { detail: $elem });
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (i === $elements.length - 1) {
|
if (i === $elements.length - 1) {
|
||||||
|
@ -87,15 +86,4 @@ Eyeline.prototype.update = function() {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Call this when we know aren't loading any more elements. Mark the rest as seen
|
|
||||||
Eyeline.prototype.flushRest = function() {
|
|
||||||
if (ENV.environment === "test") {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$(this.selector).each((i, elem) =>
|
|
||||||
this.appEvents.trigger("saw", { detail: $(elem) })
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Eyeline;
|
export default Eyeline;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user