Clean the catalog manually.
Uuuuuuggghhhhh.
This commit is contained in:
parent
a0c4d86dee
commit
cd82bce655
@ -61,12 +61,13 @@ $.extend $,
|
|||||||
else
|
else
|
||||||
req.callbacks.push cb
|
req.callbacks.push cb
|
||||||
return
|
return
|
||||||
|
rm = -> delete reqs[url]
|
||||||
req = $.ajax url,
|
req = $.ajax url,
|
||||||
onload: ->
|
onload: ->
|
||||||
cb.call @ for cb in @callbacks
|
cb.call @ for cb in @callbacks
|
||||||
delete @callbacks
|
delete @callbacks
|
||||||
onabort: -> delete reqs[url]
|
onabort: rm
|
||||||
onerror: -> delete reqs[url]
|
onerror: rm
|
||||||
req.callbacks = [cb]
|
req.callbacks = [cb]
|
||||||
reqs[url] = req
|
reqs[url] = req
|
||||||
cb:
|
cb:
|
||||||
|
|||||||
@ -1071,7 +1071,7 @@ ThreadHiding =
|
|||||||
return if g.VIEW isnt 'index' or !Conf['Thread Hiding'] and !Conf['Thread Hiding Link']
|
return if g.VIEW isnt 'index' or !Conf['Thread Hiding'] and !Conf['Thread Hiding Link']
|
||||||
|
|
||||||
@db = new DataBoard 'hiddenThreads'
|
@db = new DataBoard 'hiddenThreads'
|
||||||
@syncFromCatalog()
|
@syncCatalog()
|
||||||
Thread::callbacks.push
|
Thread::callbacks.push
|
||||||
name: 'Thread Hiding'
|
name: 'Thread Hiding'
|
||||||
cb: @node
|
cb: @node
|
||||||
@ -1082,7 +1082,7 @@ ThreadHiding =
|
|||||||
return unless Conf['Thread Hiding']
|
return unless Conf['Thread Hiding']
|
||||||
$.prepend @OP.nodes.root, ThreadHiding.makeButton @, 'hide'
|
$.prepend @OP.nodes.root, ThreadHiding.makeButton @, 'hide'
|
||||||
|
|
||||||
syncFromCatalog: ->
|
syncCatalog: ->
|
||||||
# Sync hidden threads from the catalog into the index.
|
# Sync hidden threads from the catalog into the index.
|
||||||
hiddenThreads = ThreadHiding.db.get
|
hiddenThreads = ThreadHiding.db.get
|
||||||
boardID: g.BOARD.ID
|
boardID: g.BOARD.ID
|
||||||
@ -1099,10 +1099,30 @@ ThreadHiding =
|
|||||||
unless threadID of hiddenThreadsOnCatalog
|
unless threadID of hiddenThreadsOnCatalog
|
||||||
delete hiddenThreads[threadID]
|
delete hiddenThreads[threadID]
|
||||||
|
|
||||||
|
if (ThreadHiding.db.data.lastChecked or 0) > Date.now() - $.MINUTE
|
||||||
|
# Was cleaned just now.
|
||||||
|
ThreadHiding.cleanCatalog()
|
||||||
|
|
||||||
ThreadHiding.db.set
|
ThreadHiding.db.set
|
||||||
boardID: g.BOARD.ID
|
boardID: g.BOARD.ID
|
||||||
val: hiddenThreads
|
val: hiddenThreads
|
||||||
|
|
||||||
|
cleanCatalog: ->
|
||||||
|
# We need to clean hidden threads on the catalog ourselves,
|
||||||
|
# otherwise if we don't visit the catalog regularly
|
||||||
|
# it will pollute the localStorage and our data.
|
||||||
|
$.ajax "//api.4chan.org/#{g.BOARD}/threads.json", onload: (e) ->
|
||||||
|
return unless @status is 200
|
||||||
|
threads = {}
|
||||||
|
for page in JSON.parse e.target.response
|
||||||
|
for thread in page.threads
|
||||||
|
if thread.no of hiddenThreadsOnCatalog
|
||||||
|
threads[thread.no] = hiddenThreadsOnCatalog[thread.no]
|
||||||
|
if Object.keys(threads).length
|
||||||
|
localStorage.setItem "4chan-hide-t-#{g.BOARD}", threads
|
||||||
|
else
|
||||||
|
localStorage.removeItem "4chan-hide-t-#{g.BOARD}"
|
||||||
|
|
||||||
menu:
|
menu:
|
||||||
init: ->
|
init: ->
|
||||||
return if g.VIEW isnt 'index' or !Conf['Menu'] or !Conf['Thread Hiding Link']
|
return if g.VIEW isnt 'index' or !Conf['Menu'] or !Conf['Thread Hiding Link']
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user