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') @computed('topics.@each')
lastVisitedTopic() { lastVisitedTopic() {
if (!this.get('highlightLastVisited')) { return; }
let user = Discourse.User.current(); let user = Discourse.User.current();
if (!user || !user.previous_visit_at) { if (!user || !user.previous_visit_at) {
return; return;
} }
let prevVisit = user.get('previousVisitAt');
let prevTopic, topic; let prevTopic, topic;
prevTopic = this.get('prevTopic');
if (prevTopic) {
return prevTopic;
}
let prevVisit = user.get('previousVisitAt');
let skipPinned = true; let skipPinned = true;
this.get('topics').any(t => { this.get('topics').any(t => {
@ -53,11 +60,16 @@ export default Ember.Component.extend({
return t.get('bumpedAt') < prevVisit; return t.get('bumpedAt') < prevVisit;
}); });
if (!prevTopic || !topic) { if (!prevTopic || !topic) {
return; return;
} }
// end of list that was scanned
if (topic.get('bumpedAt') > prevVisit) {
return;
}
this.set('prevTopic', prevTopic);
return prevTopic; return prevTopic;
}, },

View File

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