Add Dismiss posts quoting you item to Thread Watcher menu to unhighlight the icon and threads until there are new replies quoting you.
This commit is contained in:
parent
63fefa2357
commit
f718dd7a04
@ -132,6 +132,10 @@ ThreadWatcher =
|
|||||||
ThreadWatcher.db.delete {siteID, boardID, threadID}
|
ThreadWatcher.db.delete {siteID, boardID, threadID}
|
||||||
ThreadWatcher.refresh()
|
ThreadWatcher.refresh()
|
||||||
$.event 'CloseMenu'
|
$.event 'CloseMenu'
|
||||||
|
dismiss: ->
|
||||||
|
for {siteID, boardID, threadID, data} in ThreadWatcher.getAll() when data.quotingYou
|
||||||
|
ThreadWatcher.update siteID, boardID, threadID, {dismiss: data.quotingYou or 0}
|
||||||
|
$.event 'CloseMenu'
|
||||||
toggle: ->
|
toggle: ->
|
||||||
{thread} = Get.postFromNode @
|
{thread} = Get.postFromNode @
|
||||||
ThreadWatcher.toggle thread
|
ThreadWatcher.toggle thread
|
||||||
@ -345,7 +349,7 @@ ThreadWatcher =
|
|||||||
|
|
||||||
lastReadPost = ThreadWatcher.unreaddb.get {siteID, boardID, threadID, defaultValue: 0}
|
lastReadPost = ThreadWatcher.unreaddb.get {siteID, boardID, threadID, defaultValue: 0}
|
||||||
unread = data.unread or 0
|
unread = data.unread or 0
|
||||||
quotingYou = data.quotingYou or false
|
quotingYou = data.quotingYou or 0
|
||||||
youOP = !!QuoteYou.db?.get {siteID, boardID, threadID, postID: threadID}
|
youOP = !!QuoteYou.db?.get {siteID, boardID, threadID, postID: threadID}
|
||||||
|
|
||||||
for postObj in @response.posts
|
for postObj in @response.posts
|
||||||
@ -354,9 +358,9 @@ ThreadWatcher =
|
|||||||
continue if Filter.isHidden(site.Build.parseJSON postObj, boardID, siteID)
|
continue if Filter.isHidden(site.Build.parseJSON postObj, boardID, siteID)
|
||||||
|
|
||||||
unread++
|
unread++
|
||||||
quotingYou = true if !Conf['Require OP Quote Link'] and youOP
|
quotingYou = postObj.no if !Conf['Require OP Quote Link'] and youOP
|
||||||
|
|
||||||
continue unless !quotingYou and QuoteYou.db and postObj.com
|
continue unless QuoteYou.db and postObj.com
|
||||||
|
|
||||||
regexp = site.regexp.quotelinkHTML
|
regexp = site.regexp.quotelinkHTML
|
||||||
regexp.lastIndex = 0
|
regexp.lastIndex = 0
|
||||||
@ -367,7 +371,7 @@ ThreadWatcher =
|
|||||||
threadID: match[2] or threadID
|
threadID: match[2] or threadID
|
||||||
postID: match[3] or match[2] or threadID
|
postID: match[3] or match[2] or threadID
|
||||||
}
|
}
|
||||||
quotingYou = true
|
quotingYou = postObj.no
|
||||||
break
|
break
|
||||||
|
|
||||||
newData or= {}
|
newData or= {}
|
||||||
@ -436,7 +440,7 @@ ThreadWatcher =
|
|||||||
if ThreadWatcher.unreadEnabled and Conf['Show Unread Count']
|
if ThreadWatcher.unreadEnabled and Conf['Show Unread Count']
|
||||||
$.addClass div, 'replies-read' if data.unread is 0
|
$.addClass div, 'replies-read' if data.unread is 0
|
||||||
$.addClass div, 'replies-unread' if data.unread
|
$.addClass div, 'replies-unread' if data.unread
|
||||||
$.addClass div, 'replies-quoting-you' if data.quotingYou
|
$.addClass div, 'replies-quoting-you' if (data.quotingYou or 0) > (data.dismiss or 0)
|
||||||
$.add div, [x, $.tn(' '), link]
|
$.add div, [x, $.tn(' '), link]
|
||||||
div
|
div
|
||||||
|
|
||||||
@ -546,7 +550,11 @@ ThreadWatcher =
|
|||||||
ThreadWatcher.addRaw boardID, threadID, data, cb
|
ThreadWatcher.addRaw boardID, threadID, data, cb
|
||||||
|
|
||||||
addRaw: (boardID, threadID, data, cb) ->
|
addRaw: (boardID, threadID, data, cb) ->
|
||||||
ThreadWatcher.db.set {boardID, threadID, val: data}, cb
|
oldData = ThreadWatcher.db.get {boardID, threadID, defaultValue: {}}
|
||||||
|
delete oldData.last
|
||||||
|
delete oldData.modified
|
||||||
|
$.extend oldData, data
|
||||||
|
ThreadWatcher.db.set {boardID, threadID, val: oldData}, cb
|
||||||
ThreadWatcher.refresh()
|
ThreadWatcher.refresh()
|
||||||
thread = {siteID: g.SITE.ID, boardID, threadID, data, force: true}
|
thread = {siteID: g.SITE.ID, boardID, threadID, data, force: true}
|
||||||
if Conf['Show Page'] and !data.isDead
|
if Conf['Show Page'] and !data.isDead
|
||||||
@ -603,11 +611,21 @@ ThreadWatcher =
|
|||||||
@el.classList.toggle 'disabled', !$('.dead-thread', ThreadWatcher.list)
|
@el.classList.toggle 'disabled', !$('.dead-thread', ThreadWatcher.list)
|
||||||
true
|
true
|
||||||
|
|
||||||
for {text, cb, open} in entries
|
# `Dismiss posts quoting you` entry
|
||||||
|
entries.push
|
||||||
|
text: 'Dismiss posts quoting you'
|
||||||
|
title: 'Unhighlight the thread watcher icon and threads until there are new replies quoting you.'
|
||||||
|
cb: ThreadWatcher.cb.dismiss
|
||||||
|
open: ->
|
||||||
|
@el.classList.toggle 'disabled', !$.hasClass(ThreadWatcher.shortcut, 'replies-quoting-you')
|
||||||
|
true
|
||||||
|
|
||||||
|
for {text, title, cb, open} in entries
|
||||||
entry =
|
entry =
|
||||||
el: $.el 'a',
|
el: $.el 'a',
|
||||||
textContent: text
|
textContent: text
|
||||||
href: 'javascript:;'
|
href: 'javascript:;'
|
||||||
|
entry.el.title = title if title
|
||||||
$.on entry.el, 'click', cb
|
$.on entry.el, 'click', cb
|
||||||
entry.open = open.bind(entry)
|
entry.open = open.bind(entry)
|
||||||
@menu.addEntry entry
|
@menu.addEntry entry
|
||||||
|
|||||||
@ -145,13 +145,13 @@ Unread =
|
|||||||
return if @isFetchedQuote or @isClone
|
return if @isFetchedQuote or @isClone
|
||||||
Unread.order.push @
|
Unread.order.push @
|
||||||
return if @ID <= Unread.lastReadPost or @isHidden or QuoteYou.isYou(@)
|
return if @ID <= Unread.lastReadPost or @isHidden or QuoteYou.isYou(@)
|
||||||
Unread.posts.add @ID
|
Unread.posts.add (Unread.posts.last = @ID)
|
||||||
Unread.addPostQuotingYou @
|
Unread.addPostQuotingYou @
|
||||||
Unread.position ?= Unread.order[@ID]
|
Unread.position ?= Unread.order[@ID]
|
||||||
|
|
||||||
addPostQuotingYou: (post) ->
|
addPostQuotingYou: (post) ->
|
||||||
for quotelink in post.nodes.quotelinks when QuoteYou.db?.get Get.postDataFromLink quotelink
|
for quotelink in post.nodes.quotelinks when QuoteYou.db?.get Get.postDataFromLink quotelink
|
||||||
Unread.postsQuotingYou.add post.ID
|
Unread.postsQuotingYou.add (Unread.postsQuotingYou.last = post.ID)
|
||||||
Unread.openNotification post
|
Unread.openNotification post
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -270,8 +270,18 @@ Unread =
|
|||||||
saveThreadWatcherCount: $.debounce 2 * $.SECOND, ->
|
saveThreadWatcherCount: $.debounce 2 * $.SECOND, ->
|
||||||
$.forceSync 'Remember Last Read Post'
|
$.forceSync 'Remember Last Read Post'
|
||||||
if Conf['Remember Last Read Post'] and (!Unread.thread.isDead or Unread.thread.isArchived)
|
if Conf['Remember Last Read Post'] and (!Unread.thread.isDead or Unread.thread.isArchived)
|
||||||
|
quotingYou = if !Conf['Require OP Quote Link'] and QuoteYou.isYou(Unread.thread.OP) then Unread.posts else Unread.postsQuotingYou
|
||||||
|
if !quotingYou.size
|
||||||
|
quotingYou.last = 0
|
||||||
|
else if !quotingYou.has(quotingYou.last)
|
||||||
|
quotingYou.last = 0
|
||||||
|
posts = Unread.thread.posts.keys
|
||||||
|
for i in [posts.length - 1 .. 0] by -1
|
||||||
|
if quotingYou.has(+posts[i])
|
||||||
|
quotingYou.last = posts[i]
|
||||||
|
break
|
||||||
ThreadWatcher.update g.SITE.ID, Unread.thread.board.ID, Unread.thread.ID,
|
ThreadWatcher.update g.SITE.ID, Unread.thread.board.ID, Unread.thread.ID,
|
||||||
last: Unread.thread.lastPost
|
last: Unread.thread.lastPost
|
||||||
isDead: Unread.thread.isDead
|
isDead: Unread.thread.isDead
|
||||||
unread: Unread.posts.size
|
unread: Unread.posts.size
|
||||||
quotingYou: !!(if !Conf['Require OP Quote Link'] and QuoteYou.isYou(Unread.thread.OP) then Unread.posts.size else Unread.postsQuotingYou.size)
|
quotingYou: (quotingYou.last or 0)
|
||||||
|
|||||||
@ -104,4 +104,4 @@ UnreadIndex =
|
|||||||
ThreadWatcher.update g.SITE.ID, thread.board.ID, thread.ID,
|
ThreadWatcher.update g.SITE.ID, thread.board.ID, thread.ID,
|
||||||
last: thread.lastPost
|
last: thread.lastPost
|
||||||
unread: 0
|
unread: 0
|
||||||
quotingYou: false
|
quotingYou: 0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user