From 0e8fade6466cc2e4027d55af3df4de7016613ebc Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sun, 3 Apr 2016 21:34:19 -0700 Subject: [PATCH] Scrolling to post hidden by Reply Pruning unhides post. This includes 'Scroll to Last Read Post'. --- src/General/Header.coffee | 6 ++++-- src/Monitoring/ReplyPruning.coffee | 5 +++++ src/Monitoring/Unread.coffee | 4 +++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/General/Header.coffee b/src/General/Header.coffee index dfa5b62e4..b7417391f 100644 --- a/src/General/Header.coffee +++ b/src/General/Header.coffee @@ -439,8 +439,10 @@ Header = return if e.state history.replaceState {}, '' unless history.state - if (hash = location.hash[1..]) and (el = $.id hash) - $.queueTask -> Header.scrollTo el + if (hash = location.hash[1..]) + ReplyPruning.showIfHidden hash + if (el = $.id hash) + $.queueTask -> Header.scrollTo el scrollTo: (root, down, needed) -> return unless root.offsetParent # hidden or fixed diff --git a/src/Monitoring/ReplyPruning.coffee b/src/Monitoring/ReplyPruning.coffee index a8cf609b4..3b9593433 100644 --- a/src/Monitoring/ReplyPruning.coffee +++ b/src/Monitoring/ReplyPruning.coffee @@ -51,6 +51,11 @@ ReplyPruning = $.event 'change', null, other $.cb.checked.call @ + showIfHidden: (id) -> + if ReplyPruning.container?.getElementById id + ReplyPruning.inputs.enabled.checked = false + $.event 'change', null, ReplyPruning.inputs.enabled + node: -> ReplyPruning.thread = @ diff --git a/src/Monitoring/Unread.coffee b/src/Monitoring/Unread.coffee index 961c7a676..d5f3a3fce 100644 --- a/src/Monitoring/Unread.coffee +++ b/src/Monitoring/Unread.coffee @@ -63,9 +63,9 @@ Unread = ready: -> Unread.setLine true + Unread.scroll() if Conf['Remember Last Read Post'] and Conf['Scroll to Last Read Post'] Unread.read() Unread.update() - Unread.scroll() if Conf['Remember Last Read Post'] and Conf['Scroll to Last Read Post'] $.on d, 'scroll visibilitychange', Unread.read $.on d, 'visibilitychange', Unread.setLine if Conf['Unread Line'] @@ -76,6 +76,8 @@ Unread = # Let the header's onload callback handle it. return if (hash = location.hash.match /\d+/) and hash[0] of Unread.thread.posts + ReplyPruning.showIfHidden Unread.position?.data.nodes.root.id + position = Unread.positionPrev() while position {root} = position.data.nodes