Separate filter combination from post DOM changes.

This commit is contained in:
ccd0 2016-10-01 15:20:24 -07:00
parent 996ad419c5
commit 545ece6c8e

View File

@ -106,34 +106,39 @@ Filter =
return false return false
settings settings
test: (post, hideable=true) ->
hl = undefined
top = false
boardID = if post.board then post.board.ID else post.boardID
for key of Filter.filters when ((value = Filter[key] post)?)
# Continue if there's nothing to filter (no tripcode for example).
for filter in Filter.filters[key] when (result = filter value, boardID, post.isReply)
{hide, stub} = result
if hide
return {hide, stub} if hideable
else
unless hl and result.class in hl
(hl or= []).push result.class
top or= result.top
{hl, top}
node: -> node: ->
return if @isClone return if @isClone
for key of Filter.filters when (value = Filter[key] @)? {hide, stub, hl, top} = Filter.test @, (!@isFetchedQuote and (@isReply or g.VIEW is 'index'))
# Continue if there's nothing to filter (no tripcode for example). if hide
if @isReply
for filter in Filter.filters[key] when result = filter value, @board.ID, @isReply PostHiding.hide @, stub
# Hide else
if result.hide and not @isFetchedQuote ThreadHiding.hide @thread, stub
if @isReply else
PostHiding.hide @, result.stub if hl
else if g.VIEW is 'index' @highlights = hl
ThreadHiding.hide @thread, result.stub $.addClass @nodes.root, hl...
else @thread.isOnTop = top
continue return
return
# Highlight
$.addClass @nodes.root, result.class
unless @highlights and result.class in @highlights
(@highlights or= []).push result.class
if !@isReply and result.top
@thread.isOnTop = true
isHidden: (post) -> isHidden: (post) ->
for key of Filter.filters when (value = Filter[key] post)? !!Filter.test(post).hide
for filter in Filter.filters[key] when result = filter value, post.boardID, post.isReply
return true if result.hide
false
postID: (post) -> "#{post.ID ? post.postID}" postID: (post) -> "#{post.ID ? post.postID}"
name: (post) -> post.info.name name: (post) -> post.info.name