Update unread count in thread watcher as posts are read.

This commit is contained in:
ccd0 2014-12-27 06:58:32 -08:00
parent 259d28385e
commit b656e6d690
2 changed files with 24 additions and 0 deletions

View File

@ -290,6 +290,25 @@ ThreadWatcher =
Index.sort()
Index.buildIndex()
update: (boardID, threadID, newData) ->
return unless data = ThreadWatcher.db?.get {boardID, threadID}
if newData.isDead and Conf['Auto Prune']
ThreadWatcher.db.delete {boardID, threadID}
ThreadWatcher.refresh()
return
n = 0
n++ for key, val of newData when data[key] isnt val
return unless n
ThreadWatcher.db.forceSync()
return unless data = ThreadWatcher.db.get {boardID, threadID}
$.extend data, newData
ThreadWatcher.db.set {boardID, threadID, val: data}
if line = $ "#watched-threads > [data-full-i-d='#{boardID}.#{threadID}']", ThreadWatcher.dialog
newLine = ThreadWatcher.makeLine boardID, threadID, data
$.replace line, newLine
else
ThreadWatcher.refresh()
toggle: (thread) ->
boardID = thread.board.ID
threadID = thread.ID

View File

@ -219,6 +219,11 @@ Unread =
Unread.title
d.title = "#{titleQuotingYou}#{titleCount}#{titleDead}"
ThreadWatcher.update Unread.thread.board.ID, Unread.thread.ID,
isDead: Unread.thread.isDead
unread: count
quotingYou: countQuotingYou
return unless Conf['Unread Favicon']
Favicon.el.href =