From acf31945b1abe029d5bd43ed67f39a4af6d2549b Mon Sep 17 00:00:00 2001 From: ccd0 Date: Mon, 9 Mar 2015 00:56:13 -0700 Subject: [PATCH] Make MarkNewIPs use deletedPosts. --- src/Monitoring/MarkNewIPs.coffee | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/Monitoring/MarkNewIPs.coffee b/src/Monitoring/MarkNewIPs.coffee index 263d7e53a..456658c89 100644 --- a/src/Monitoring/MarkNewIPs.coffee +++ b/src/Monitoring/MarkNewIPs.coffee @@ -7,29 +7,21 @@ MarkNewIPs = node: -> MarkNewIPs.ipCount = @ipCount - MarkNewIPs.postIDs = (+x for x in @posts.keys) $.on d, 'ThreadUpdate', MarkNewIPs.onUpdate onUpdate: (e) -> - {ipCount, newPosts} = e.detail - {postIDs} = ThreadUpdater + {ipCount, newPosts, deletedPosts} = e.detail return unless ipCount? - if newPosts.length - obj = {} - obj[x] = true for x in MarkNewIPs.postIDs - added = 0 - added++ for x in postIDs when not (x of obj) - removed = MarkNewIPs.postIDs.length + added - postIDs.length - switch ipCount - MarkNewIPs.ipCount - when added - i = MarkNewIPs.ipCount - for fullID in newPosts - MarkNewIPs.markNew g.posts[fullID], ++i - when -removed - for fullID in newPosts - MarkNewIPs.markOld g.posts[fullID] + + switch ipCount - MarkNewIPs.ipCount + when newPosts.length + i = MarkNewIPs.ipCount + for fullID in newPosts + MarkNewIPs.markNew g.posts[fullID], ++i + when -deletedPosts.length + for fullID in newPosts + MarkNewIPs.markOld g.posts[fullID] MarkNewIPs.ipCount = ipCount - MarkNewIPs.postIDs = postIDs markNew: (post, ipCount) -> suffix = if (ipCount // 10) % 10 is 1