Fix bug from v1.13.0.3 causing threads to be incorrectly pruned / marked dead in Thread Watcher.

Fixes bug from 293fca67dda7091916cf7483ff6d021cb25cf73c.
This commit is contained in:
ccd0 2016-10-04 19:40:01 -07:00
parent 62b9e9f8dc
commit 3a98275bb0
2 changed files with 5 additions and 3 deletions

View File

@ -614,6 +614,8 @@ Index =
Build.spoilerRange[g.BOARD.ID] = Index.liveThreadData[0].custom_spoiler
g.BOARD.threads.forEach (thread) ->
(thread.collect() unless thread.ID in Index.liveThreadIDs)
$.event 'IndexUpdate',
threads: ("#{g.BOARD}.#{ID}" for ID in Index.liveThreadIDs)
return
isHidden: (threadID) ->

View File

@ -28,7 +28,7 @@ ThreadWatcher =
switch g.VIEW
when 'index'
$.on d, 'IndexRefreshInternal', @cb.onIndexRefresh
$.on d, 'IndexUpdate', @cb.onIndexUpdate
when 'thread'
$.on d, 'ThreadUpdate', @cb.onThreadRefresh
@ -139,11 +139,11 @@ ThreadWatcher =
ThreadWatcher.addRaw boardID, threadID, {}
else if Conf['Auto Watch Reply']
ThreadWatcher.add g.threads[boardID + '.' + threadID]
onIndexRefresh: ->
onIndexUpdate: (e) ->
{db} = ThreadWatcher
boardID = g.BOARD.ID
nKilled = 0
for threadID, data of db.data.boards[boardID] when not data?.isDead and threadID not of g.BOARD.threads
for threadID, data of db.data.boards[boardID] when not data?.isDead and "#{boardID}.#{threadID}" not in e.detail.threads
nKilled++
if Conf['Auto Prune'] or not (data and typeof data is 'object') # corrupt data
db.delete {boardID, threadID}