Partial: unread counter in Thread Watcher
This commit is contained in:
parent
b56d4cce8c
commit
5b0a1111a9
@ -14,6 +14,8 @@ ThreadWatcher =
|
|||||||
@status = $ '#watcher-status', @dialog
|
@status = $ '#watcher-status', @dialog
|
||||||
@list = @dialog.lastElementChild
|
@list = @dialog.lastElementChild
|
||||||
|
|
||||||
|
@unreaddb = new DataBoard 'lastReadPosts'
|
||||||
|
|
||||||
$.on d, 'QRPostSuccessful', @cb.post
|
$.on d, 'QRPostSuccessful', @cb.post
|
||||||
$.on sc, 'click', @toggleWatcher
|
$.on sc, 'click', @toggleWatcher
|
||||||
$.on $('.move>.close', ThreadWatcher.dialog), 'click', @toggleWatcher
|
$.on $('.move>.close', ThreadWatcher.dialog), 'click', @toggleWatcher
|
||||||
@ -132,15 +134,34 @@ ThreadWatcher =
|
|||||||
else
|
else
|
||||||
status = "#{Math.round fetchCount.fetched / fetchCount.fetching * 100}%"
|
status = "#{Math.round fetchCount.fetched / fetchCount.fetching * 100}%"
|
||||||
ThreadWatcher.status.textContent = status
|
ThreadWatcher.status.textContent = status
|
||||||
return if @status isnt 404
|
return if @status isnt 404 and @status isnt 200
|
||||||
if Conf['Auto Prune']
|
|
||||||
ThreadWatcher.db.delete {boardID, threadID}
|
if @status is 200
|
||||||
else
|
lastReadPost = ThreadWatcher.unreaddb.get
|
||||||
data.isDead = true
|
boardID: boardID
|
||||||
ThreadWatcher.db.set {boardID, threadID, val: data}
|
threadID: threadID
|
||||||
|
defaultValue: 0
|
||||||
|
|
||||||
|
unread = 0
|
||||||
|
|
||||||
|
for postObj in @response.posts
|
||||||
|
if postObj.no > lastReadPost
|
||||||
|
unread++
|
||||||
|
|
||||||
|
return if unread is data.unread
|
||||||
|
|
||||||
|
data.unread = unread
|
||||||
|
|
||||||
|
if @status is 404
|
||||||
|
if Conf['Auto Prune']
|
||||||
|
ThreadWatcher.db.delete {boardID, threadID}
|
||||||
|
else
|
||||||
|
data.isDead = true
|
||||||
|
ThreadWatcher.db.set {boardID, threadID, val: data}
|
||||||
|
|
||||||
ThreadWatcher.refresh()
|
ThreadWatcher.refresh()
|
||||||
,
|
,
|
||||||
type: 'head'
|
type: 'get'
|
||||||
|
|
||||||
getAll: ->
|
getAll: ->
|
||||||
all = []
|
all = []
|
||||||
@ -161,7 +182,7 @@ ThreadWatcher =
|
|||||||
href = Redirect.to 'thread', {boardID, threadID}
|
href = Redirect.to 'thread', {boardID, threadID}
|
||||||
link = $.el 'a',
|
link = $.el 'a',
|
||||||
href: href or "/#{boardID}/thread/#{threadID}"
|
href: href or "/#{boardID}/thread/#{threadID}"
|
||||||
textContent: data.excerpt
|
textContent: data.excerpt + " (#{data.unread})"
|
||||||
title: data.excerpt
|
title: data.excerpt
|
||||||
|
|
||||||
div = $.el 'div'
|
div = $.el 'div'
|
||||||
@ -201,7 +222,7 @@ ThreadWatcher =
|
|||||||
else
|
else
|
||||||
ThreadWatcher.add thread
|
ThreadWatcher.add thread
|
||||||
add: (thread) ->
|
add: (thread) ->
|
||||||
data = {}
|
data = {unread: 0}
|
||||||
boardID = thread.board.ID
|
boardID = thread.board.ID
|
||||||
threadID = thread.ID
|
threadID = thread.ID
|
||||||
if thread.isDead
|
if thread.isDead
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user