FIX: While browsing, last read should be based on the eyeline
This commit is contained in:
parent
c9689d4dad
commit
4661c4274c
|
@ -199,13 +199,15 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
|
||||||
if (!post) { return; }
|
if (!post) { return; }
|
||||||
|
|
||||||
const postNumber = post.get('post_number');
|
const postNumber = post.get('post_number');
|
||||||
const model = this.get('model');
|
const topic = this.get('model');
|
||||||
model.set('currentPost', postNumber);
|
topic.set('currentPost', postNumber);
|
||||||
|
if (postNumber > (topic.get('last_read_post_number') || 0)) {
|
||||||
|
topic.set('last_read_post_id', post.get('id'));
|
||||||
|
topic.set('last_read_post_number', postNumber);
|
||||||
|
}
|
||||||
|
|
||||||
this.send('postChangedRoute', postNumber);
|
this.send('postChangedRoute', postNumber);
|
||||||
|
this._progressIndex = topic.get('postStream').progressIndexOfPost(post);
|
||||||
const postStream = model.get('postStream');
|
|
||||||
|
|
||||||
this._progressIndex = postStream.progressIndexOfPost(post);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
currentPostScrolled(event) {
|
currentPostScrolled(event) {
|
||||||
|
@ -849,38 +851,23 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
|
||||||
const postStream = topic.get("postStream");
|
const postStream = topic.get("postStream");
|
||||||
|
|
||||||
if (topic.get('id') === topicId) {
|
if (topic.get('id') === topicId) {
|
||||||
|
|
||||||
let highestReadPostId = 0;
|
|
||||||
|
|
||||||
// TODO identity map for postNumber
|
|
||||||
postStream.get('posts').forEach(post => {
|
postStream.get('posts').forEach(post => {
|
||||||
if (!post.read && postNumbers.indexOf(post.post_number) !== -1) {
|
if (!post.read && postNumbers.indexOf(post.post_number) !== -1) {
|
||||||
const id = post.get('id');
|
|
||||||
if (id > highestReadPostId) {
|
|
||||||
highestReadPostId = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
post.set('read', true);
|
post.set('read', true);
|
||||||
this.appEvents.trigger('post-stream:refresh', { id });
|
this.appEvents.trigger('post-stream:refresh', { id: post.get('id') });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (highestReadPostId > 0 && highestReadPostId > (topic.get('last_read_post_id') || 0)) {
|
|
||||||
topic.set('last_read_post_id', highestReadPostId);
|
|
||||||
}
|
|
||||||
|
|
||||||
const max = _.max(postNumbers);
|
|
||||||
if (max > (topic.get("last_read_post_number") || 0)) {
|
|
||||||
topic.set("last_read_post_number", max);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.siteSettings.automatically_unpin_topics &&
|
if (this.siteSettings.automatically_unpin_topics &&
|
||||||
this.currentUser &&
|
this.currentUser &&
|
||||||
this.currentUser.automatically_unpin_topics) {
|
this.currentUser.automatically_unpin_topics) {
|
||||||
|
|
||||||
// automatically unpin topics when the user reaches the bottom
|
// automatically unpin topics when the user reaches the bottom
|
||||||
|
const max = _.max(postNumbers);
|
||||||
if (topic.get("pinned") && max >= topic.get("highest_post_number")) {
|
if (topic.get("pinned") && max >= topic.get("highest_post_number")) {
|
||||||
Em.run.next(() => topic.clearPin());
|
Em.run.next(() => topic.clearPin());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue