Make MarkNewIPs use deletedPosts.

This commit is contained in:
ccd0 2015-03-09 00:56:13 -07:00
parent 39e33ddccf
commit acf31945b1

View File

@ -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