Don't nuke DataBoards when threads.json 404s, as 4chan fucks up often.

This commit is contained in:
Mayhem 2013-08-24 16:51:32 +02:00
parent d4dc96edc6
commit 667abe7480

View File

@ -70,18 +70,15 @@ class DataBoard
@save() @save()
ajaxClean: (boardID) -> ajaxClean: (boardID) ->
$.cache "//api.4chan.org/#{boardID}/threads.json", (e) => $.cache "//api.4chan.org/#{boardID}/threads.json", (e) =>
if e.target.status is 404 return if e.target.status isnt 200
# Deleted board. board = @data.boards[boardID]
@delete boardID threads = {}
else if e.target.status is 200 for page in JSON.parse e.target.response
board = @data.boards[boardID] for thread in page.threads
threads = {} if thread.no of board
for page in JSON.parse e.target.response threads[thread.no] = board[thread.no]
for thread in page.threads @data.boards[boardID] = threads
if thread.no of board @deleteIfEmpty {boardID}
threads[thread.no] = board[thread.no]
@data.boards[boardID] = threads
@deleteIfEmpty {boardID}
@save() @save()
onSync: (data) => onSync: (data) =>