Expand at least comments when the thread itself cannot be expanded. #968

This commit is contained in:
Nicolas Stepien 2013-04-05 01:26:48 +02:00
parent c79bb318b2
commit caa79b5089

View File

@ -1101,13 +1101,13 @@ ThreadHiding =
if (ThreadHiding.db.data.lastChecked or 0) > Date.now() - $.MINUTE if (ThreadHiding.db.data.lastChecked or 0) > Date.now() - $.MINUTE
# Was cleaned just now. # Was cleaned just now.
ThreadHiding.cleanCatalog() ThreadHiding.cleanCatalog hiddenThreadsOnCatalog
ThreadHiding.db.set ThreadHiding.db.set
boardID: g.BOARD.ID boardID: g.BOARD.ID
val: hiddenThreads val: hiddenThreads
cleanCatalog: -> cleanCatalog: (hiddenThreadsOnCatalog) ->
# We need to clean hidden threads on the catalog ourselves, # We need to clean hidden threads on the catalog ourselves,
# otherwise if we don't visit the catalog regularly # otherwise if we don't visit the catalog regularly
# it will pollute the localStorage and our data. # it will pollute the localStorage and our data.
@ -3505,22 +3505,31 @@ ExpandThread =
toggle: (thread) -> toggle: (thread) ->
threadRoot = thread.OP.nodes.root.parentNode threadRoot = thread.OP.nodes.root.parentNode
url = "//api.4chan.org/#{thread.board}/res/#{thread}.json"
a = $ '.summary', threadRoot a = $ '.summary', threadRoot
text = a.textContent
switch text[0] switch thread.isExpanded
when '+' when false, undefined
a.textContent = text.replace '+', '× Loading...' thread.isExpanded = 'loading'
$.cache url, -> ExpandThread.parse @, thread, a
for post in $$ '.thread > .postContainer', threadRoot for post in $$ '.thread > .postContainer', threadRoot
ExpandComment.expand Get.postFromRoot post ExpandComment.expand Get.postFromRoot post
unless a
thread.isExpanded = true
return
thread.isExpanded = 'loading'
a.textContent = a.textContent.replace '+', '× Loading...'
$.cache "//api.4chan.org/#{thread.board}/res/#{thread}.json", ->
ExpandThread.parse @, thread, a
when '×' when 'loading'
a.textContent = text.replace '× Loading...', '+' thread.isExpanded = false
return unless a
a.textContent = a.textContent.replace '× Loading...', '+'
when '-' when true
a.textContent = text.replace '-', '+' thread.isExpanded = false
if a
a.textContent = a.textContent.replace '-', '+'
#goddamit moot #goddamit moot
num = if thread.isSticky num = if thread.isSticky
1 1
@ -3547,6 +3556,7 @@ ExpandThread =
$.off a, 'click', ExpandThread.cb.toggle $.off a, 'click', ExpandThread.cb.toggle
return return
thread.isExpanded = true
a.textContent = a.textContent.replace '× Loading...', '-' a.textContent = a.textContent.replace '× Loading...', '-'
posts = JSON.parse(req.response).posts posts = JSON.parse(req.response).posts