Fix race condition causing unread posts tracking to malfunction.

This commit is contained in:
ccd0 2021-05-07 00:47:29 -07:00
parent 0308b7ace8
commit 36a3e7cdcc
2 changed files with 15 additions and 7 deletions

View File

@ -1,13 +1,22 @@
Favicon =
init: ->
$.asap (-> d.head and (Favicon.el = $ 'link[rel="shortcut icon"]', d.head)), Favicon.initAsap
set: (status) ->
Favicon.status = status
if Favicon.el
Favicon.el.href = Favicon[status]
# `favicon.href = href` doesn't work on Firefox.
$.add d.head, Favicon.el
initAsap: ->
Favicon.el.type = 'image/x-icon'
{href} = Favicon.el
Favicon.isSFW = /ws\.ico$/.test href
Favicon.default = href
Favicon.switch()
if Favicon.status
Favicon.set Favicon.status
switch: ->
items = {

View File

@ -236,15 +236,14 @@ Unread =
if Conf['Unread Favicon'] and g.SITE.software is 'yotsuba'
{isDead} = Unread.thread
Favicon.el.href =
Favicon.set (
if countQuotingYou
Favicon[if isDead then 'unreadDeadY' else 'unreadY']
(if isDead then 'unreadDeadY' else 'unreadY')
else if count
Favicon[if isDead then 'unreadDead' else 'unread']
(if isDead then 'unreadDead' else 'unread')
else
Favicon[if isDead then 'dead' else 'default']
# `favicon.href = href` doesn't work on Firefox.
$.add d.head, Favicon.el
(if isDead then 'dead' else 'default')
)
saveThreadWatcherCount: $.debounce 2 * $.SECOND, ->
$.forceSync 'Remember Last Read Post'