Avoid needless Thread Watcher rebuild by using ThreadWatcher.update when possible.
This commit is contained in:
parent
4c454e6f93
commit
af00c711ff
@ -93,16 +93,16 @@ ThreadWatcher =
|
|||||||
href: 'javascript:;'
|
href: 'javascript:;'
|
||||||
className: 'watch-thread-link'
|
className: 'watch-thread-link'
|
||||||
$.before $('input', @nodes.info), toggler
|
$.before $('input', @nodes.info), toggler
|
||||||
|
siteID = Site.hostname
|
||||||
boardID = @board.ID
|
boardID = @board.ID
|
||||||
threadID = @thread.ID
|
threadID = @thread.ID
|
||||||
data = ThreadWatcher.db.get {boardID, threadID}
|
data = ThreadWatcher.db.get {siteID, boardID, threadID}
|
||||||
ThreadWatcher.setToggler toggler, !!data
|
ThreadWatcher.setToggler toggler, !!data
|
||||||
$.on toggler, 'click', ThreadWatcher.cb.toggle
|
$.on toggler, 'click', ThreadWatcher.cb.toggle
|
||||||
# Add missing excerpt for threads added by Auto Watch
|
# Add missing excerpt for threads added by Auto Watch
|
||||||
if data and not data.excerpt?
|
if data and not data.excerpt?
|
||||||
$.queueTask =>
|
$.queueTask =>
|
||||||
ThreadWatcher.db.extend {boardID, threadID, val: {excerpt: Get.threadExcerpt @thread}}
|
ThreadWatcher.update siteID, boardID, threadID, val: {excerpt: Get.threadExcerpt @thread}
|
||||||
ThreadWatcher.refresh()
|
|
||||||
|
|
||||||
catalogNode: ->
|
catalogNode: ->
|
||||||
$.addClass @nodes.root, 'watched' if ThreadWatcher.isWatched @thread
|
$.addClass @nodes.root, 'watched' if ThreadWatcher.isWatched @thread
|
||||||
@ -344,19 +344,13 @@ ThreadWatcher =
|
|||||||
if quotesYou and not Filter.isHidden(Build.parseJSON postObj, boardID)
|
if quotesYou and not Filter.isHidden(Build.parseJSON postObj, boardID)
|
||||||
quotingYou = true
|
quotingYou = true
|
||||||
|
|
||||||
updated = (isDead isnt data.isDead or unread isnt data.unread or quotingYou isnt data.quotingYou)
|
ThreadWatcher.update siteID, boardID, threadID, {last, replies, isDead, unread, quotingYou}
|
||||||
ThreadWatcher.db.extend {siteID, boardID, threadID, val: {last, replies, isDead, unread, quotingYou}}
|
|
||||||
ThreadWatcher.refresh() if updated
|
|
||||||
|
|
||||||
else if @status is 404
|
else if @status is 404
|
||||||
if SW[software].mayLackJSON and !data.last?
|
if SW[software].mayLackJSON and !data.last?
|
||||||
ThreadWatcher.db.extend {siteID, boardID, threadID, val: {last: -1, unread: undefined, quotingYou: undefined}}
|
ThreadWatcher.update siteID, boardID, threadID, {last: -1, unread: undefined, quotingYou: undefined}
|
||||||
else if Conf['Auto Prune']
|
|
||||||
ThreadWatcher.db.delete {siteID, boardID, threadID}
|
|
||||||
else
|
else
|
||||||
ThreadWatcher.db.extend {siteID, boardID, threadID, val: {isDead: true, unread: undefined, quotingYou: undefined}}
|
ThreadWatcher.update siteID, boardID, threadID, {isDead: true, unread: undefined, quotingYou: undefined}
|
||||||
|
|
||||||
ThreadWatcher.refresh()
|
|
||||||
|
|
||||||
getAll: (groupByBoard) ->
|
getAll: (groupByBoard) ->
|
||||||
all = []
|
all = []
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user