Only display in discovery, correct double highlighting

This commit is contained in:
Sam 2016-08-19 12:43:48 +10:00
parent 11f9a463ac
commit 9b1e81cd6d
2 changed files with 15 additions and 2 deletions

View File

@ -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;
},

View File

@ -33,6 +33,7 @@
{{#if hasTopics}}
{{topic-list
highlightLastVisited=true
showTopicPostBadges=showTopicPostBadges
showPosters=true
currentUser=currentUser