A platform for community discussion. Free, open, simple.
DEV: Triggering "saw" on every element seems pointless
Robin Ward091d6dc9fce1
diff --git a/app/assets/javascripts/discourse/components/discovery-topics-list.js b/app/assets/javascripts/discourse/components/discovery-topics-list.jsindex 30a0118a339..28ab1efab59 100644--- a/app/assets/javascripts/discourse/components/discovery-topics-list.js+++ b/app/assets/javascripts/discourse/components/discovery-topics-list.js@@ -38,9 +38,7 @@ const DiscoveryTopicsListComponent = Component.extend(UrlRefresh, LoadMore, {Discourse.updateContextCount(0);this.model.loadMore().then(hasMoreResults => {schedule("afterRender", () => this.saveScrollPosition());- if (!hasMoreResults) {- this.eyeline.flushRest();- } else if ($(window).height() >= $(document).height()) {+ if (hasMoreResults && $(window).height() >= $(document).height()) {this.send("loadMore");}});diff --git a/app/assets/javascripts/discourse/components/user-stream.js b/app/assets/javascripts/discourse/components/user-stream.jsindex 62d9fe7f0d8..aadd188699a 100644--- a/app/assets/javascripts/discourse/components/user-stream.js+++ b/app/assets/javascripts/discourse/components/user-stream.js@@ -110,10 +110,7 @@ export default Component.extend(LoadMore, {this.set("loading", true);const stream = this.stream;- stream.findItems().then(() => {- this.set("loading", false);- this.eyeline.flushRest();- });+ stream.findItems().then(() => this.set("loading", false));}}});diff --git a/app/assets/javascripts/discourse/lib/eyeline.js b/app/assets/javascripts/discourse/lib/eyeline.jsindex d31602e4da0..53f2a8435ad 100644--- a/app/assets/javascripts/discourse/lib/eyeline.js+++ b/app/assets/javascripts/discourse/lib/eyeline.js@@ -78,7 +78,6 @@ Eyeline.prototype.update = function() {// If you hit the bottom we mark all the elements as seen. Otherwise, just the first oneif (!atBottom) {- appEvents.trigger("saw", { detail: $elem });return false;}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;