Autodetect when board doesn't have archive when cleaning history. #525

Also remove data from any boards that have been deleted.
This commit is contained in:
ccd0 2015-11-07 14:18:09 -08:00
parent 50a0e2c82d
commit 5eb7808f96

View File

@ -82,21 +82,19 @@ class DataBoard
ajaxClean: (boardID) ->
$.cache "//a.4cdn.org/#{boardID}/threads.json", (e1) =>
if e1.target.status is 200
if boardID in ['b', 'f', 'trash']
@ajaxCleanParse boardID, e1.target.response
else
$.cache "//a.4cdn.org/#{boardID}/archive.json", (e2) =>
if e2.target.status is 200
@ajaxCleanParse boardID, e1.target.response, e2.target.response
return unless e1.target.status in [200, 404]
$.cache "//a.4cdn.org/#{boardID}/archive.json", (e2) =>
return unless e2.target.status in [200, 404]
@ajaxCleanParse boardID, e1.target.response, e2.target.response
ajaxCleanParse: (boardID, response1, response2) ->
board = @data.boards[boardID]
threads = {}
for page in response1
for thread in page.threads
ID = thread.no
threads[ID] = board[ID] if ID of board
if response1
for page in response1
for thread in page.threads
ID = thread.no
threads[ID] = board[ID] if ID of board
if response2
for ID in response2
threads[ID] = board[ID] if ID of board