Add hidden threads count on the index.
Conflicts: src/Filtering/ThreadHiding.coffee
This commit is contained in:
parent
1f982020f6
commit
3af338f23d
@ -19,7 +19,29 @@ ThreadHiding =
|
|||||||
thread = Get.threadFromRoot root
|
thread = Get.threadFromRoot root
|
||||||
if thread.isHidden and thread.stub and !root.contains thread.stub
|
if thread.isHidden and thread.stub and !root.contains thread.stub
|
||||||
ThreadHiding.makeStub thread, root
|
ThreadHiding.makeStub thread, root
|
||||||
return
|
ThreadHiding.updateToggle()
|
||||||
|
updateToggle: ->
|
||||||
|
hiddenCount = 0
|
||||||
|
for threadID, thread of g.BOARD.threads when thread.isHidden
|
||||||
|
hiddenCount++ if thread.ID in Index.liveThreadIDs
|
||||||
|
unless hiddenCount
|
||||||
|
ThreadHiding.removeToggle()
|
||||||
|
return
|
||||||
|
unless ThreadHiding.toggler
|
||||||
|
ThreadHiding.addToggle()
|
||||||
|
$('#hidden-count', Index.navLinks).textContent = if hiddenCount is 1
|
||||||
|
'1 hidden thread'
|
||||||
|
else
|
||||||
|
"#{hiddenCount} hidden threads"
|
||||||
|
addToggle: ->
|
||||||
|
ThreadHiding.toggler = $.el 'span',
|
||||||
|
id: 'hidden-label'
|
||||||
|
innerHTML: ' — <span id="hidden-count"></span>'
|
||||||
|
$.add Index.navLinks, ThreadHiding.toggler
|
||||||
|
removeToggle: ->
|
||||||
|
return unless ThreadHiding.toggler
|
||||||
|
$.rm ThreadHiding.toggler
|
||||||
|
delete ThreadHiding.toggler
|
||||||
|
|
||||||
syncCatalog: ->
|
syncCatalog: ->
|
||||||
# Sync hidden threads from the catalog into the index.
|
# Sync hidden threads from the catalog into the index.
|
||||||
@ -188,6 +210,7 @@ ThreadHiding =
|
|||||||
return if thread.isHidden
|
return if thread.isHidden
|
||||||
threadRoot = thread.OP.nodes.root.parentNode
|
threadRoot = thread.OP.nodes.root.parentNode
|
||||||
thread.isHidden = true
|
thread.isHidden = true
|
||||||
|
ThreadHiding.updateToggle()
|
||||||
|
|
||||||
return threadRoot.hidden = true unless makeStub
|
return threadRoot.hidden = true unless makeStub
|
||||||
|
|
||||||
@ -199,3 +222,4 @@ ThreadHiding =
|
|||||||
delete thread.stub
|
delete thread.stub
|
||||||
threadRoot = thread.OP.nodes.root.parentNode
|
threadRoot = thread.OP.nodes.root.parentNode
|
||||||
threadRoot.hidden = thread.isHidden = false
|
threadRoot.hidden = thread.isHidden = false
|
||||||
|
ThreadHiding.updateToggle()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user