From b3f937f5c8ff79089df7b21cd38d2cba713a958c Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Sun, 16 Feb 2014 03:11:27 -0700 Subject: [PATCH 1/2] Fix JSON Navigation unread count --- builds/4chan-X.user.js | 30 +++++++++++++----------------- builds/crx/script.js | 30 +++++++++++++----------------- src/General/Navigate.coffee | 12 ++++++------ src/Monitoring/Unread.coffee | 11 ++++++----- 4 files changed, 38 insertions(+), 45 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 35d337803..77bc6f1db 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -10024,13 +10024,13 @@ ready: function() { var posts; $.off(d, '4chanXInitFinished', Unread.ready); - posts = []; - Unread.thread.posts.forEach(function(post) { - if (post.isReply) { - return posts.push(post); - } - }); if (!Conf['Quote Threading']) { + posts = []; + Unread.thread.posts.forEach(function(post) { + if (post.isReply) { + return posts.push(post); + } + }); Unread.addPosts(posts); } if (Conf['Quote Threading']) { @@ -10101,9 +10101,7 @@ })) { continue; } - if (!(post.prev || post.next)) { - Unread.posts.push(post); - } + Unread.posts.push(post); Unread.addPostQuotingYou(post); } if (Conf['Unread Line']) { @@ -10148,7 +10146,7 @@ onUpdate: function(e) { if (e.detail[404]) { return Unread.update(); - } else { + } else if (!Conf['Quote Threading']) { return Unread.addPosts(e.detail.newPosts); } }, @@ -12296,11 +12294,11 @@ }, updateContext: function(view) { var oldView; - if (view === g.VIEW) { - return; + g.DEAD = false; + if (view !== g.VIEW) { + $.rmClass(doc, g.VIEW); + $.addClass(doc, view); } - $.rmClass(doc, g.VIEW); - $.addClass(doc, view); oldView = g.VIEW; g.VIEW = view; return { @@ -12532,7 +12530,6 @@ Main.callbackNodes(Thread, [thread]); Main.callbackNodes(Post, posts); Navigate.ready('Quote Threading', QuoteThreading.force, Conf['Quote Threading'] && !Conf['Unread Count']); - Navigate.ready('Unread Count', Unread.ready, Conf['Unread Count']); Navigate.buildThread(); return Header.hashScroll.call(window); }, @@ -12542,8 +12539,7 @@ $.rmAll(board); $.add(board, [Navigate.threadRoot, $.el('hr')]); if (Conf['Unread Count']) { - Unread.read(); - return Unread.update(); + return Navigate.ready('Unread Count', Unread.ready, Conf['Unread Count']); } }, popstate: function() { diff --git a/builds/crx/script.js b/builds/crx/script.js index b931ff4ce..9ca9a18ac 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -10015,13 +10015,13 @@ ready: function() { var posts; $.off(d, '4chanXInitFinished', Unread.ready); - posts = []; - Unread.thread.posts.forEach(function(post) { - if (post.isReply) { - return posts.push(post); - } - }); if (!Conf['Quote Threading']) { + posts = []; + Unread.thread.posts.forEach(function(post) { + if (post.isReply) { + return posts.push(post); + } + }); Unread.addPosts(posts); } if (Conf['Quote Threading']) { @@ -10092,9 +10092,7 @@ })) { continue; } - if (!(post.prev || post.next)) { - Unread.posts.push(post); - } + Unread.posts.push(post); Unread.addPostQuotingYou(post); } if (Conf['Unread Line']) { @@ -10139,7 +10137,7 @@ onUpdate: function(e) { if (e.detail[404]) { return Unread.update(); - } else { + } else if (!Conf['Quote Threading']) { return Unread.addPosts(e.detail.newPosts); } }, @@ -12293,11 +12291,11 @@ }, updateContext: function(view) { var oldView; - if (view === g.VIEW) { - return; + g.DEAD = false; + if (view !== g.VIEW) { + $.rmClass(doc, g.VIEW); + $.addClass(doc, view); } - $.rmClass(doc, g.VIEW); - $.addClass(doc, view); oldView = g.VIEW; g.VIEW = view; return { @@ -12529,7 +12527,6 @@ Main.callbackNodes(Thread, [thread]); Main.callbackNodes(Post, posts); Navigate.ready('Quote Threading', QuoteThreading.force, Conf['Quote Threading'] && !Conf['Unread Count']); - Navigate.ready('Unread Count', Unread.ready, Conf['Unread Count']); Navigate.buildThread(); return Header.hashScroll.call(window); }, @@ -12539,8 +12536,7 @@ $.rmAll(board); $.add(board, [Navigate.threadRoot, $.el('hr')]); if (Conf['Unread Count']) { - Unread.read(); - return Unread.update(); + return Navigate.ready('Unread Count', Unread.ready, Conf['Unread Count']); } }, popstate: function() { diff --git a/src/General/Navigate.coffee b/src/General/Navigate.coffee index 9795831a0..1fd197446 100644 --- a/src/General/Navigate.coffee +++ b/src/General/Navigate.coffee @@ -86,10 +86,12 @@ Navigate = QR.generatePostableThreadsList() updateContext: (view) -> - return if view is g.VIEW + g.DEAD = false + + unless view is g.VIEW + $.rmClass doc, g.VIEW + $.addClass doc, view - $.rmClass doc, g.VIEW - $.addClass doc, view oldView = g.VIEW g.VIEW = view { @@ -287,7 +289,6 @@ Navigate = Main.callbackNodes Post, posts Navigate.ready 'Quote Threading', QuoteThreading.force, Conf['Quote Threading'] and not Conf['Unread Count'] - Navigate.ready 'Unread Count', Unread.ready, Conf['Unread Count'] Navigate.buildThread() Header.hashScroll.call window @@ -298,8 +299,7 @@ Navigate = $.add board, [Navigate.threadRoot, $.el 'hr'] if Conf['Unread Count'] - Unread.read() - Unread.update() + Navigate.ready 'Unread Count', Unread.ready, Conf['Unread Count'] popstate: -> return if window.location.pathname is Navigate.path diff --git a/src/Monitoring/Unread.coffee b/src/Monitoring/Unread.coffee index 1814c9a29..267d38fe6 100755 --- a/src/Monitoring/Unread.coffee +++ b/src/Monitoring/Unread.coffee @@ -41,9 +41,10 @@ Unread = ready: -> $.off d, '4chanXInitFinished', Unread.ready - posts = [] - Unread.thread.posts.forEach (post) -> posts.push post if post.isReply - Unread.addPosts posts unless Conf['Quote Threading'] + unless Conf['Quote Threading'] + posts = [] + Unread.thread.posts.forEach (post) -> posts.push post if post.isReply + Unread.addPosts posts QuoteThreading.force() if Conf['Quote Threading'] Unread.scroll() if Conf['Scroll to Last Read Post'] @@ -91,7 +92,7 @@ Unread = threadID: post.thread.ID postID: ID } - Unread.posts.push post unless post.prev or post.next + Unread.posts.push post Unread.addPostQuotingYou post if Conf['Unread Line'] # Force line on visible threads if there were no unread posts previously. @@ -125,7 +126,7 @@ Unread = onUpdate: (e) -> if e.detail[404] Unread.update() - else + else if !Conf['Quote Threading'] Unread.addPosts e.detail.newPosts readSinglePost: (post) -> From 6649e8519c2be71b4c5137e91527dcd50ee446c5 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Sun, 16 Feb 2014 03:15:23 -0700 Subject: [PATCH 2/2] Fix unread count + thread updater with quote threading enabled See guys, fix one thing, break another! --- builds/4chan-X.user.js | 3 +++ builds/crx/script.js | 3 +++ src/Monitoring/Unread.coffee | 3 +++ 3 files changed, 9 insertions(+) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 77bc6f1db..11f188ac5 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -10148,6 +10148,9 @@ return Unread.update(); } else if (!Conf['Quote Threading']) { return Unread.addPosts(e.detail.newPosts); + } else { + Unread.read(); + return Unread.update(); } }, readSinglePost: function(post) { diff --git a/builds/crx/script.js b/builds/crx/script.js index 9ca9a18ac..2106eb18c 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -10139,6 +10139,9 @@ return Unread.update(); } else if (!Conf['Quote Threading']) { return Unread.addPosts(e.detail.newPosts); + } else { + Unread.read(); + return Unread.update(); } }, readSinglePost: function(post) { diff --git a/src/Monitoring/Unread.coffee b/src/Monitoring/Unread.coffee index 267d38fe6..262b4867b 100755 --- a/src/Monitoring/Unread.coffee +++ b/src/Monitoring/Unread.coffee @@ -128,6 +128,9 @@ Unread = Unread.update() else if !Conf['Quote Threading'] Unread.addPosts e.detail.newPosts + else + Unread.read() + Unread.update() readSinglePost: (post) -> {ID} = post