FIX: Mark ignored posts as 'read', if last visible post is read (#7739)

This commit is contained in:
David Taylor 2019-06-11 12:16:28 +01:00 committed by GitHub
parent 000a35b219
commit 61b587f66e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 0 deletions

View File

@ -104,6 +104,28 @@ export default class {
const topicId = parseInt(this._topicId, 10);
let highestSeen = 0;
// Workaround to avoid ignored posts being "stuck unread"
const controller = this._topicController;
const stream = controller ? controller.get("model.postStream") : null;
if (
this.currentUser && // Logged in
this.currentUser.get("ignored_users.length") && // At least 1 user is ignored
stream && // Sanity check
stream.hasNoFilters && // The stream is not filtered (by username or summary)
!stream.canAppendMore && // We are at the end of the stream
stream.posts.lastObject && // The last post exists
stream.posts.lastObject.read && // The last post is read
!!stream.gaps.after[stream.posts.lastObject.id] && // Stream ends with a gap
stream.topic.last_read_post_number !==
stream.posts.lastObject.post_number +
stream.get(`gaps.after.${stream.posts.lastObject.id}.length`) // The last post in the gap has not been marked read
) {
newTimings[
stream.posts.lastObject.post_number +
stream.get(`gaps.after.${stream.posts.lastObject.id}.length`)
] = 1;
}
Object.keys(newTimings).forEach(postNumber => {
highestSeen = Math.max(highestSeen, parseInt(postNumber, 10));
});