From 9fd5a8824240f759113569943a6ecc325d378bcf Mon Sep 17 00:00:00 2001 From: ccd0 Date: Thu, 13 Dec 2018 20:44:02 -0800 Subject: [PATCH] Quick fix for issues on lainchan due to not accounting for post container. --- src/Monitoring/UnreadIndex.coffee | 2 +- src/main/Main.coffee | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Monitoring/UnreadIndex.coffee b/src/Monitoring/UnreadIndex.coffee index 67e0ff111..46606aef8 100644 --- a/src/Monitoring/UnreadIndex.coffee +++ b/src/Monitoring/UnreadIndex.coffee @@ -56,7 +56,7 @@ UnreadIndex = repliesRead = 0 firstUnread = null thread.posts.forEach (post) -> - if post.isReply and post.nodes.root.parentNode is thread.nodes.root + if post.isReply and thread.nodes.root.contains(post.nodes.root) repliesShown++ if post.ID <= lastReadPost repliesRead++ diff --git a/src/main/Main.coffee b/src/main/Main.coffee index 9f39bb877..d607d5ab3 100644 --- a/src/main/Main.coffee +++ b/src/main/Main.coffee @@ -379,7 +379,7 @@ Main = addThreads: (records) -> threadRoots = [] for record in records - for node in record.addedNodes when node.matches(Site.selectors.thread) + for node in record.addedNodes when node.nodeType is Node.ELEMENT_NODE and node.matches(Site.selectors.thread) threadRoots.push node return unless threadRoots.length threads = [] @@ -398,8 +398,12 @@ Main = errors = [] for record in records thread = Get.threadFromRoot record.target + postRoots = [] + for node in record.addedNodes when node.nodeType is Node.ELEMENT_NODE + if node.matches(Site.selectors.postContainer) or (node = $(Site.selectors.postContainer, node)) + postRoots.push node n = posts.length - Main.parsePosts record.addedNodes, thread, posts, errors + Main.parsePosts postRoots, thread, posts, errors if posts.length > n and thread not in threads threads.push thread anyRemoved = false