From daa3f9d2cc92bda8236d245788aec8960633fe01 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Tue, 13 Jan 2015 12:09:15 -0700 Subject: [PATCH] Fix a small navigation error --- builds/appchan-x.user.js | 6 +++--- builds/crx/script.js | 6 +++--- src/General/Header.coffee | 2 +- src/General/Navigate.coffee | 3 ++- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/builds/appchan-x.user.js b/builds/appchan-x.user.js index 558faa708..6c70e4e6d 100644 --- a/builds/appchan-x.user.js +++ b/builds/appchan-x.user.js @@ -4793,7 +4793,7 @@ if (!(/^p\d+$/.test(hash) && (post = $.id(hash)))) { return; } - if ((Get.postFromRoot(post)).isHidden) { + if (!(post = Get.postFromRoot(post)) || post.isHidden) { return; } return Header.scrollTo(post); @@ -18864,11 +18864,11 @@ $.rmAll(board); $.add(board, [threadRoot, $.el('hr')]); QR.generatePostableThreadsList(); - Header.hashScroll.call(window); if (errors) { Main.handleErrors(errors); } - return $.event('4chanXInitFinished'); + $.event('4chanXInitFinished'); + return Header.hashScroll.call(window); }, pushState: function(path) { history.pushState(null, '', path); diff --git a/builds/crx/script.js b/builds/crx/script.js index 4fd9230f1..04284c2d3 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -4811,7 +4811,7 @@ if (!(/^p\d+$/.test(hash) && (post = $.id(hash)))) { return; } - if ((Get.postFromRoot(post)).isHidden) { + if (!(post = Get.postFromRoot(post)) || post.isHidden) { return; } return Header.scrollTo(post); @@ -18890,11 +18890,11 @@ $.rmAll(board); $.add(board, [threadRoot, $.el('hr')]); QR.generatePostableThreadsList(); - Header.hashScroll.call(window); if (errors) { Main.handleErrors(errors); } - return $.event('4chanXInitFinished'); + $.event('4chanXInitFinished'); + return Header.hashScroll.call(window); }, pushState: function(path) { history.pushState(null, '', path); diff --git a/src/General/Header.coffee b/src/General/Header.coffee index 99fb4e3ec..693d396cf 100644 --- a/src/General/Header.coffee +++ b/src/General/Header.coffee @@ -354,7 +354,7 @@ Header = hashScroll: -> hash = @location.hash[1..] return unless /^p\d+$/.test(hash) and post = $.id hash - return if (Get.postFromRoot post).isHidden + return if !(post = Get.postFromRoot post) or post.isHidden Header.scrollTo post scrollTo: (root, down, needed) -> diff --git a/src/General/Navigate.coffee b/src/General/Navigate.coffee index aa15cd808..318fa94d8 100644 --- a/src/General/Navigate.coffee +++ b/src/General/Navigate.coffee @@ -354,13 +354,14 @@ Navigate = $.add board, [threadRoot, $.el 'hr'] QR.generatePostableThreadsList() - Header.hashScroll.call window Main.handleErrors errors if errors # Thrown after thread has been generated and features have been parsed, like 4chan X $.event '4chanXInitFinished' + Header.hashScroll.call window + pushState: (path) -> history.pushState null, '', path Navigate.path = window.location.pathname