Merge commit 'ef89d9324' (notification filters)
This commit is contained in:
commit
35213df61e
@ -64,6 +64,9 @@ Filter =
|
|||||||
else
|
else
|
||||||
Conf['Stubs']
|
Conf['Stubs']
|
||||||
|
|
||||||
|
# Desktop notification
|
||||||
|
noti = /notify/.test filter
|
||||||
|
|
||||||
# Highlight the post, or hide it.
|
# Highlight the post, or hide it.
|
||||||
# If not specified, the highlight class will be filter-highlight.
|
# If not specified, the highlight class will be filter-highlight.
|
||||||
# Defaults to post hiding.
|
# Defaults to post hiding.
|
||||||
@ -82,7 +85,7 @@ Filter =
|
|||||||
else
|
else
|
||||||
types = ['subject', 'name', 'filename', 'comment']
|
types = ['subject', 'name', 'filename', 'comment']
|
||||||
|
|
||||||
filter = @createFilter regexp, boards, excludes, op, stub, hl, top
|
filter = @createFilter regexp, boards, excludes, op, stub, hl, top, noti
|
||||||
if key is 'general'
|
if key is 'general'
|
||||||
for type in types
|
for type in types
|
||||||
(@filters[type] or= []).push filter
|
(@filters[type] or= []).push filter
|
||||||
@ -94,7 +97,7 @@ Filter =
|
|||||||
name: 'Filter'
|
name: 'Filter'
|
||||||
cb: @node
|
cb: @node
|
||||||
|
|
||||||
createFilter: (regexp, boards, excludes, op, stub, hl, top) ->
|
createFilter: (regexp, boards, excludes, op, stub, hl, top, noti) ->
|
||||||
test =
|
test =
|
||||||
if typeof regexp is 'string'
|
if typeof regexp is 'string'
|
||||||
# MD5 checking
|
# MD5 checking
|
||||||
@ -103,10 +106,11 @@ Filter =
|
|||||||
(value) -> regexp.test value
|
(value) -> regexp.test value
|
||||||
|
|
||||||
settings =
|
settings =
|
||||||
hide: !hl
|
hide: !(hl or noti)
|
||||||
stub: stub
|
stub: stub
|
||||||
class: hl
|
class: hl
|
||||||
top: top
|
top: top
|
||||||
|
noti: noti
|
||||||
|
|
||||||
(value, boardID, isReply) ->
|
(value, boardID, isReply) ->
|
||||||
if boards and boardID not in boards
|
if boards and boardID not in boards
|
||||||
@ -125,6 +129,7 @@ Filter =
|
|||||||
stub = true
|
stub = true
|
||||||
hl = undefined
|
hl = undefined
|
||||||
top = false
|
top = false
|
||||||
|
noti = false
|
||||||
if QuoteYou.isYou(post)
|
if QuoteYou.isYou(post)
|
||||||
hideable = false
|
hideable = false
|
||||||
for key of Filter.filters when ((value = Filter[key] post)?)
|
for key of Filter.filters when ((value = Filter[key] post)?)
|
||||||
@ -138,14 +143,16 @@ Filter =
|
|||||||
unless hl and result.class in hl
|
unless hl and result.class in hl
|
||||||
(hl or= []).push result.class
|
(hl or= []).push result.class
|
||||||
top or= result.top
|
top or= result.top
|
||||||
|
if result.noti
|
||||||
|
noti = true
|
||||||
if hide
|
if hide
|
||||||
{hide, stub}
|
{hide, stub}
|
||||||
else
|
else
|
||||||
{hl, top}
|
{hl, top, noti}
|
||||||
|
|
||||||
node: ->
|
node: ->
|
||||||
return if @isClone
|
return if @isClone
|
||||||
{hide, stub, hl, top} = Filter.test @, (!@isFetchedQuote and (@isReply or g.VIEW is 'index'))
|
{hide, stub, hl, top, noti} = Filter.test @, (!@isFetchedQuote and (@isReply or g.VIEW is 'index'))
|
||||||
if hide
|
if hide
|
||||||
if @isReply
|
if @isReply
|
||||||
PostHiding.hide @, stub
|
PostHiding.hide @, stub
|
||||||
@ -155,7 +162,8 @@ Filter =
|
|||||||
if hl
|
if hl
|
||||||
@highlights = hl
|
@highlights = hl
|
||||||
$.addClass @nodes.root, hl...
|
$.addClass @nodes.root, hl...
|
||||||
return
|
if noti and Unread.posts and (@ID > Unread.lastReadPost) and not QuoteYou.isYou(@)
|
||||||
|
Unread.openNotification @, ' triggered a notification filter'
|
||||||
|
|
||||||
isHidden: (post) ->
|
isHidden: (post) ->
|
||||||
!!Filter.test(post).hide
|
!!Filter.test(post).hide
|
||||||
|
|||||||
@ -30,6 +30,10 @@
|
|||||||
Highlighted OPs will have their threads put on top of the board index by default.<br>
|
Highlighted OPs will have their threads put on top of the board index by default.<br>
|
||||||
For example: <code>top:yes;</code> or <code>top:no;</code>.
|
For example: <code>top:yes;</code> or <code>top:no;</code>.
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
Show a desktop notification instead of hiding.<br>
|
||||||
|
For example: <code>notify;</code>.
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
Filters in the "General" section apply to multiple fields, by default <code>subject,name,filename,comment</code>.<br>
|
Filters in the "General" section apply to multiple fields, by default <code>subject,name,filename,comment</code>.<br>
|
||||||
The fields can be specified with the <code>type</code> option, separated by commas.<br>
|
The fields can be specified with the <code>type</code> option, separated by commas.<br>
|
||||||
|
|||||||
@ -125,9 +125,9 @@ Unread =
|
|||||||
Unread.openNotification post
|
Unread.openNotification post
|
||||||
return
|
return
|
||||||
|
|
||||||
openNotification: (post) ->
|
openNotification: (post, predicate=' replied to you') ->
|
||||||
return unless Header.areNotificationsEnabled
|
return unless Header.areNotificationsEnabled
|
||||||
notif = new Notification "#{post.info.nameBlock} replied to you",
|
notif = new Notification "#{post.info.nameBlock}#{predicate}",
|
||||||
body: post.commentDisplay()
|
body: post.commentDisplay()
|
||||||
icon: Favicon.logo
|
icon: Favicon.logo
|
||||||
notif.onclick = ->
|
notif.onclick = ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user