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