From 6bd1d44b680975162de32abc352d65cae27cfeb1 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Fri, 10 Jan 2014 18:55:33 -0700 Subject: [PATCH] Unread Count actually requires the nodes to be on the page Unfortunately --- builds/4chan-X.user.js | 27 +++++++++++++-------------- builds/crx/script.js | 27 +++++++++++++-------------- src/General/Navigate.coffee | 3 +++ src/General/lib/databoard.class | 6 +++--- src/Monitoring/Unread.coffee | 4 ++-- 5 files changed, 34 insertions(+), 33 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 4c1d71fde..86fd16646 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -1473,16 +1473,9 @@ }; DataBoard.prototype.disconnect = function() { - var key, _i, _len, _results; $.desync(this.key); - _results = []; - for (_i = 0, _len = this.length; _i < _len; _i++) { - key = this[_i]; - if (this.hasOwnKey(key)) { - _results.push(delete this[key]); - } - } - return _results; + delete this.sync; + return delete this.data; }; return DataBoard; @@ -9680,13 +9673,13 @@ }); }, disconnect: function() { - var hr, name, parent, _i, _len, _ref; + var hr, name, _i, _len, _ref; if (!Unread.db) { return; } Unread.db.disconnect(); - if (parent = (hr = Unread.hr).parentElement) { - $.rm(hr, parent); + if (hr = Unread.hr, Unread) { + $.rm(hr); } _ref = ['db', 'hr', 'posts', 'postsQuotingYou', 'thread', 'title', 'lastReadPost']; for (_i = 0, _len = _ref.length; _i < _len; _i++) { @@ -9727,7 +9720,9 @@ posts.push(post); } } - Unread.addPosts(posts); + if (!Conf['Quote Threading']) { + Unread.addPosts(posts); + } if (Conf['Quote Threading']) { QuoteThreading.force(); } @@ -12132,7 +12127,11 @@ var board; board = $('.board'); $.rmAll(board); - return $.add(board, Navigate.threadRoot); + $.add(board, Navigate.threadRoot); + if (Conf['Unread Count']) { + Unread.read(); + return Unread.update(); + } }, popstate: function() { var a; diff --git a/builds/crx/script.js b/builds/crx/script.js index 23f1d84d1..c849267e3 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1479,16 +1479,9 @@ }; DataBoard.prototype.disconnect = function() { - var key, _i, _len, _results; $.desync(this.key); - _results = []; - for (_i = 0, _len = this.length; _i < _len; _i++) { - key = this[_i]; - if (this.hasOwnKey(key)) { - _results.push(delete this[key]); - } - } - return _results; + delete this.sync; + return delete this.data; }; return DataBoard; @@ -9663,13 +9656,13 @@ }); }, disconnect: function() { - var hr, name, parent, _i, _len, _ref; + var hr, name, _i, _len, _ref; if (!Unread.db) { return; } Unread.db.disconnect(); - if (parent = (hr = Unread.hr).parentElement) { - $.rm(hr, parent); + if (hr = Unread.hr, Unread) { + $.rm(hr); } _ref = ['db', 'hr', 'posts', 'postsQuotingYou', 'thread', 'title', 'lastReadPost']; for (_i = 0, _len = _ref.length; _i < _len; _i++) { @@ -9710,7 +9703,9 @@ posts.push(post); } } - Unread.addPosts(posts); + if (!Conf['Quote Threading']) { + Unread.addPosts(posts); + } if (Conf['Quote Threading']) { QuoteThreading.force(); } @@ -12121,7 +12116,11 @@ var board; board = $('.board'); $.rmAll(board); - return $.add(board, Navigate.threadRoot); + $.add(board, Navigate.threadRoot); + if (Conf['Unread Count']) { + Unread.read(); + return Unread.update(); + } }, popstate: function() { return Navigate.popstate = function() { diff --git a/src/General/Navigate.coffee b/src/General/Navigate.coffee index 4fffe15c4..b4a584e1b 100644 --- a/src/General/Navigate.coffee +++ b/src/General/Navigate.coffee @@ -280,6 +280,9 @@ Navigate = board = $ '.board' $.rmAll board $.add board, Navigate.threadRoot + if Conf['Unread Count'] + Unread.read() + Unread.update() popstate: -> <% if (type === 'crx') { %> Navigate.popstate = -> <% } %> # blink/webkit throw a popstate on page load. Not what we want. a = $.el 'a', diff --git a/src/General/lib/databoard.class b/src/General/lib/databoard.class index 9318ff542..ff0162aad 100755 --- a/src/General/lib/databoard.class +++ b/src/General/lib/databoard.class @@ -13,8 +13,7 @@ class DataBoard @sync = sync $.on d, '4chanXInitFinished', init - save: -> - $.set @key, @data + save: -> $.set @key, @data delete: ({boardID, threadID, postID}) -> if postID @@ -93,4 +92,5 @@ class DataBoard disconnect: -> $.desync @key - delete @[key] for key in @ when @hasOwnKey key \ No newline at end of file + delete @sync + delete @data \ No newline at end of file diff --git a/src/Monitoring/Unread.coffee b/src/Monitoring/Unread.coffee index b5d78772b..50ec64859 100755 --- a/src/Monitoring/Unread.coffee +++ b/src/Monitoring/Unread.coffee @@ -16,7 +16,7 @@ Unread = return unless Unread.db Unread.db.disconnect() - $.rm hr, parent if parent = (hr = Unread.hr).parentElement + $.rm hr if {hr} = Unread delete @[name] for name in ['db', 'hr', 'posts', 'postsQuotingYou', 'thread', 'title', 'lastReadPost'] @@ -43,7 +43,7 @@ Unread = $.off d, '4chanXInitFinished', Unread.ready posts = [] posts.push post for ID, post of Unread.thread.posts when post.isReply - Unread.addPosts posts + Unread.addPosts posts unless Conf['Quote Threading'] QuoteThreading.force() if Conf['Quote Threading'] Unread.scroll() if Conf['Scroll to Last Read Post']