make unread count in thread watcher optional
This commit is contained in:
parent
77bacb0d2b
commit
6ae8662d7d
@ -486,6 +486,10 @@ Config =
|
|||||||
false
|
false
|
||||||
'Automatically prune 404\'d threads.'
|
'Automatically prune 404\'d threads.'
|
||||||
]
|
]
|
||||||
|
'Show Unread Count': [
|
||||||
|
true
|
||||||
|
'Show number of unread posts in watched threads.'
|
||||||
|
]
|
||||||
|
|
||||||
filter:
|
filter:
|
||||||
name: """
|
name: """
|
||||||
|
|||||||
@ -134,9 +134,8 @@ 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 and @status isnt 200
|
|
||||||
|
|
||||||
if @status is 200
|
if @status is 200 and @response
|
||||||
lastReadPost = ThreadWatcher.unreaddb.get
|
lastReadPost = ThreadWatcher.unreaddb.get
|
||||||
boardID: boardID
|
boardID: boardID
|
||||||
threadID: threadID
|
threadID: threadID
|
||||||
@ -148,21 +147,20 @@ ThreadWatcher =
|
|||||||
if postObj.no > lastReadPost
|
if postObj.no > lastReadPost
|
||||||
unread++
|
unread++
|
||||||
|
|
||||||
return if unread is data.unread
|
if unread isnt data.unread
|
||||||
|
data.unread = unread
|
||||||
|
ThreadWatcher.db.set {boardID, threadID, val: data}
|
||||||
|
ThreadWatcher.refresh()
|
||||||
|
|
||||||
data.unread = unread
|
else if @status is 404
|
||||||
ThreadWatcher.db.set {boardID, threadID, val: data}
|
|
||||||
|
|
||||||
if @status is 404
|
|
||||||
if Conf['Auto Prune']
|
if Conf['Auto Prune']
|
||||||
ThreadWatcher.db.delete {boardID, threadID}
|
ThreadWatcher.db.delete {boardID, threadID}
|
||||||
else
|
else
|
||||||
data.isDead = true
|
data.isDead = true
|
||||||
ThreadWatcher.db.set {boardID, threadID, val: data}
|
ThreadWatcher.db.set {boardID, threadID, val: data}
|
||||||
|
ThreadWatcher.refresh()
|
||||||
ThreadWatcher.refresh()
|
|
||||||
,
|
,
|
||||||
type: 'get'
|
type: if Conf['Show Unread Count'] then 'get' else 'head'
|
||||||
|
|
||||||
getAll: ->
|
getAll: ->
|
||||||
all = []
|
all = []
|
||||||
@ -184,7 +182,7 @@ ThreadWatcher =
|
|||||||
className: 'watcher-title'
|
className: 'watcher-title'
|
||||||
|
|
||||||
count = $.el 'span',
|
count = $.el 'span',
|
||||||
textContent: if data.unread? then "\u00A0(#{data.unread})" else ''
|
textContent: if Conf['Show Unread Count'] and data.unread? then "\u00A0(#{data.unread})" else ''
|
||||||
className: 'watcher-unread'
|
className: 'watcher-unread'
|
||||||
|
|
||||||
if Conf['404 Redirect'] and data.isDead
|
if Conf['404 Redirect'] and data.isDead
|
||||||
@ -243,7 +241,8 @@ ThreadWatcher =
|
|||||||
data.excerpt = Get.threadExcerpt thread
|
data.excerpt = Get.threadExcerpt thread
|
||||||
ThreadWatcher.db.set {boardID, threadID, val: data}
|
ThreadWatcher.db.set {boardID, threadID, val: data}
|
||||||
ThreadWatcher.refresh()
|
ThreadWatcher.refresh()
|
||||||
ThreadWatcher.fetchStatus {boardID, threadID, data} unless data.isDead
|
if Conf['Show Unread Count'] and !data.isDead
|
||||||
|
ThreadWatcher.fetchStatus {boardID, threadID, data}
|
||||||
rm: (boardID, threadID) ->
|
rm: (boardID, threadID) ->
|
||||||
ThreadWatcher.db.delete {boardID, threadID}
|
ThreadWatcher.db.delete {boardID, threadID}
|
||||||
ThreadWatcher.refresh()
|
ThreadWatcher.refresh()
|
||||||
@ -331,5 +330,5 @@ ThreadWatcher =
|
|||||||
entry.el.title = desc
|
entry.el.title = desc
|
||||||
input = entry.el.firstElementChild
|
input = entry.el.firstElementChild
|
||||||
$.on input, 'change', $.cb.checked
|
$.on input, 'change', $.cb.checked
|
||||||
$.on input, 'change', ThreadWatcher.refresh if name is 'Current Board'
|
$.on input, 'change', ThreadWatcher.refresh if name is 'Current Board' or name is 'Show Unread Count'
|
||||||
entry
|
entry
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user