From 8135493359f922aef5b774c2033041fb38e077f9 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Thu, 16 Jan 2014 11:19:37 -0700 Subject: [PATCH] Fix unread count for your posts, among other things --- builds/4chan-X.user.js | 16 ++++++++++------ builds/crx/script.js | 16 ++++++++++------ src/Monitoring/Unread.coffee | 14 +++++++++----- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 05e4a11be..1a8757cb3 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -9955,7 +9955,7 @@ if (!(post.prev || post.next)) { Unread.posts.push(post); } - Unread.addPostQuotingYou(post.data); + Unread.addPostQuotingYou(post); } if (Conf['Unread Line']) { Unread.setLine((_ref = Unread.posts.first.data, __indexOf.call(posts, _ref) >= 0)); @@ -10033,20 +10033,24 @@ return arr.splice(0, i); }, read: $.debounce(100, function(e) { - var ID, height, post, posts; + var ID, data, height, post, posts; if (d.hidden || !Unread.posts.length) { return; } height = doc.clientHeight; posts = Unread.posts; while (post = posts.first) { - if (!(Header.getBottomOf(post.data.nodes.root) > -1)) { + ID = post.ID, data = post.data; + if (!(Header.getBottomOf(data.nodes.root) > -1)) { break; } - ID = post.ID; posts.rm(ID); - if (Conf['Mark Quotes of You'] && post.info.yours) { - QuoteYou.lastRead = post.data.nodes.root; + if (Conf['Mark Quotes of You'] && QR.db.get({ + boardID: data.board.ID, + threadID: data.thread.ID, + postID: ID + })) { + QuoteYou.lastRead = data.nodes.root; } } if (!ID) { diff --git a/builds/crx/script.js b/builds/crx/script.js index c223d0013..d959177b8 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -9938,7 +9938,7 @@ if (!(post.prev || post.next)) { Unread.posts.push(post); } - Unread.addPostQuotingYou(post.data); + Unread.addPostQuotingYou(post); } if (Conf['Unread Line']) { Unread.setLine((_ref = Unread.posts.first.data, __indexOf.call(posts, _ref) >= 0)); @@ -10016,20 +10016,24 @@ return arr.splice(0, i); }, read: $.debounce(100, function(e) { - var ID, height, post, posts; + var ID, data, height, post, posts; if (d.hidden || !Unread.posts.length) { return; } height = doc.clientHeight; posts = Unread.posts; while (post = posts.first) { - if (!(Header.getBottomOf(post.data.nodes.root) > -1)) { + ID = post.ID, data = post.data; + if (!(Header.getBottomOf(data.nodes.root) > -1)) { break; } - ID = post.ID; posts.rm(ID); - if (Conf['Mark Quotes of You'] && post.info.yours) { - QuoteYou.lastRead = post.data.nodes.root; + if (Conf['Mark Quotes of You'] && QR.db.get({ + boardID: data.board.ID, + threadID: data.thread.ID, + postID: ID + })) { + QuoteYou.lastRead = data.nodes.root; } } if (!ID) { diff --git a/src/Monitoring/Unread.coffee b/src/Monitoring/Unread.coffee index ab5729e3b..56a610731 100755 --- a/src/Monitoring/Unread.coffee +++ b/src/Monitoring/Unread.coffee @@ -92,7 +92,7 @@ Unread = postID: ID } Unread.posts.push post unless post.prev or post.next - Unread.addPostQuotingYou post.data + Unread.addPostQuotingYou post if Conf['Unread Line'] # Force line on visible threads if there were no unread posts previously. Unread.setLine Unread.posts.first.data in posts @@ -151,12 +151,16 @@ Unread = {posts} = Unread while post = posts.first - break unless Header.getBottomOf(post.data.nodes.root) > -1 # post is not completely read - {ID} = post + {ID, data} = post + break unless Header.getBottomOf(data.nodes.root) > -1 # post is not completely read posts.rm ID - if Conf['Mark Quotes of You'] and post.info.yours - QuoteYou.lastRead = post.data.nodes.root + if Conf['Mark Quotes of You'] and QR.db.get { + boardID: data.board.ID + threadID: data.thread.ID + postID: ID + } + QuoteYou.lastRead = data.nodes.root return unless ID