diff --git a/LICENSE b/LICENSE index 78e993a3b..8b2b53748 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ /* -* appchan x - Version 2.9.32 - 2014-07-28 +* appchan x - Version 2.9.32 - 2014-07-29 * * Licensed under the MIT license. * https://github.com/zixaphir/appchan-x/blob/master/LICENSE diff --git a/builds/appchan-x.user.js b/builds/appchan-x.user.js index d56a46603..544544be1 100644 --- a/builds/appchan-x.user.js +++ b/builds/appchan-x.user.js @@ -28,7 +28,7 @@ // ==/UserScript== /* -* appchan x - Version 2.9.32 - 2014-07-28 +* appchan x - Version 2.9.32 - 2014-07-29 * * Licensed under the MIT license. * https://github.com/zixaphir/appchan-x/blob/master/LICENSE @@ -16615,14 +16615,12 @@ if (view === 'thread') { g.THREADID = +window.location.pathname.split('/')[3]; } - if (view === g.VIEW) { - return; - } - $.rmClass(doc, g.VIEW); - $.addClass(doc, view); ({ index: function() { var _ref; + if (g.VIEW === view) { + return; + } delete g.THREADID; if (Conf['Index Mode'] === 'catalog') { Index.cb.toggleCatalogMode(); @@ -16630,15 +16628,24 @@ return (_ref = QR.posts[0]) != null ? _ref.thread = 'new' : void 0; }, thread: function() { - var _ref; + var _ref, _ref1; + if (((_ref = QR.posts[0]) != null ? _ref.thread : void 0) === g.THREADID) { + return; + } if (Conf['Index Mode'] === 'catalog') { $.rmClass(doc, 'catalog-mode'); } - return (_ref = QR.posts[0]) != null ? _ref.thread = g.THREADID : void 0; + return (_ref1 = QR.posts[0]) != null ? _ref1.thread = g.THREADID : void 0; } })[view](); - QR.status(); - return g.VIEW = view; + if (view !== g.VIEW) { + $.rmClass(doc, g.VIEW); + $.addClass(doc, view); + g.VIEW = view; + } + return $.asap((function() { + return g.threads.keys.length; + }), QR.status); }, updateBoard: function(boardID) { var current, fullBoardList; diff --git a/builds/crx/script.js b/builds/crx/script.js index 2ff113bdd..3400541d3 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript /* -* appchan x - Version 2.9.32 - 2014-07-28 +* appchan x - Version 2.9.32 - 2014-07-29 * * Licensed under the MIT license. * https://github.com/zixaphir/appchan-x/blob/master/LICENSE @@ -16631,14 +16631,12 @@ if (view === 'thread') { g.THREADID = +window.location.pathname.split('/')[3]; } - if (view === g.VIEW) { - return; - } - $.rmClass(doc, g.VIEW); - $.addClass(doc, view); ({ index: function() { var _ref; + if (g.VIEW === view) { + return; + } delete g.THREADID; if (Conf['Index Mode'] === 'catalog') { Index.cb.toggleCatalogMode(); @@ -16646,15 +16644,24 @@ return (_ref = QR.posts[0]) != null ? _ref.thread = 'new' : void 0; }, thread: function() { - var _ref; + var _ref, _ref1; + if (((_ref = QR.posts[0]) != null ? _ref.thread : void 0) === g.THREADID) { + return; + } if (Conf['Index Mode'] === 'catalog') { $.rmClass(doc, 'catalog-mode'); } - return (_ref = QR.posts[0]) != null ? _ref.thread = g.THREADID : void 0; + return (_ref1 = QR.posts[0]) != null ? _ref1.thread = g.THREADID : void 0; } })[view](); - QR.status(); - return g.VIEW = view; + if (view !== g.VIEW) { + $.rmClass(doc, g.VIEW); + $.addClass(doc, view); + g.VIEW = view; + } + return $.asap((function() { + return g.threads.keys.length; + }), QR.status); }, updateBoard: function(boardID) { var current, fullBoardList; diff --git a/src/General/Navigate.coffee b/src/General/Navigate.coffee index cb1847a6b..4425ca0d1 100644 --- a/src/General/Navigate.coffee +++ b/src/General/Navigate.coffee @@ -103,28 +103,36 @@ Navigate = return updateContext: (view) -> + # State tracking g.DEAD = false g.THREADID = +window.location.pathname.split('/')[3] if view is 'thread' - return if view is g.VIEW - - $.rmClass doc, g.VIEW - $.addClass doc, view - { index: -> + # Unlike threads, boards don't need to do much when switching between them that the QR doesn't already handle. + return if g.VIEW is view delete g.THREADID Index.cb.toggleCatalogMode() if Conf['Index Mode'] is 'catalog' QR.posts[0]?.thread = 'new' thread: -> + return if QR.posts[0]?.thread is g.THREADID $.rmClass doc, 'catalog-mode' if Conf['Index Mode'] is 'catalog' + # When switching between threads, we need to update the QR state to avoid posting in the wrong thread. + # Maybe address this in a loop to update all posts to the current thread? QR.posts[0]?.thread = g.THREADID }[view]() - QR.status() # Re-enable the QR in the case of a 404'd thread or something. + if view isnt g.VIEW # index and thread are really all we care about here. + # Update some CSS selectors that depend on thread and index views. + $.rmClass doc, g.VIEW + $.addClass doc, view + # Tell the rest of the script we're no longer in the view we were. + g.VIEW = view - g.VIEW = view + # Re-enable the QR in the case of a 404'd thread or something. + # Race Condition: g.threads may not have been fully rebuilt by the time we attempt to access it. + $.asap (-> g.threads.keys.length), QR.status updateBoard: (boardID) -> fullBoardList = $ '#full-board-list', Header.boardList