Delete entire boards from DataBoards when cleaning it gives us a 404.

This would happen when a board gets deleted, like /s4s/ hopefully one day.
This commit is contained in:
Nicolas Stepien 2013-04-04 23:05:30 +02:00
parent 8bae973931
commit a0c4d86dee

View File

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