From 9b1e81cd6d84d0b99f4320301984067b6eb9652c Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 19 Aug 2016 12:43:48 +1000 Subject: [PATCH] Only display in discovery, correct double highlighting --- .../discourse/components/topic-list.js.es6 | 16 ++++++++++++++-- .../discourse/templates/discovery/topics.hbs | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/components/topic-list.js.es6 b/app/assets/javascripts/discourse/components/topic-list.js.es6 index a7c10fb4d..3066222ae 100644 --- a/app/assets/javascripts/discourse/components/topic-list.js.es6 +++ b/app/assets/javascripts/discourse/components/topic-list.js.es6 @@ -33,13 +33,20 @@ export default Ember.Component.extend({ @computed('topics.@each') lastVisitedTopic() { + if (!this.get('highlightLastVisited')) { return; } + let user = Discourse.User.current(); if (!user || !user.previous_visit_at) { return; } - let prevVisit = user.get('previousVisitAt'); let prevTopic, topic; + prevTopic = this.get('prevTopic'); + if (prevTopic) { + return prevTopic; + } + + let prevVisit = user.get('previousVisitAt'); let skipPinned = true; this.get('topics').any(t => { @@ -53,11 +60,16 @@ export default Ember.Component.extend({ return t.get('bumpedAt') < prevVisit; }); - if (!prevTopic || !topic) { return; } + // end of list that was scanned + if (topic.get('bumpedAt') > prevVisit) { + return; + } + + this.set('prevTopic', prevTopic); return prevTopic; }, diff --git a/app/assets/javascripts/discourse/templates/discovery/topics.hbs b/app/assets/javascripts/discourse/templates/discovery/topics.hbs index 4415e404c..d94b0a3e7 100644 --- a/app/assets/javascripts/discourse/templates/discovery/topics.hbs +++ b/app/assets/javascripts/discourse/templates/discovery/topics.hbs @@ -33,6 +33,7 @@ {{#if hasTopics}} {{topic-list + highlightLastVisited=true showTopicPostBadges=showTopicPostBadges showPosters=true currentUser=currentUser