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
ajaxClean: (boardID) ->
$.ajax "//api.4chan.org/#{boardID}/threads.json", onload: (e) =>
board = @data.boards[boardID]
threads = {}
for page in JSON.parse e.target.response
for thread in page.threads
if thread.no of board
threads[thread.no] = board[thread.no]
@data.boards[boardID] = threads
@deleteIfEmpty {boardID}
if e.target.status is 404
# Deleted board.
@delete boardID
else if e.target.status is 200
board = @data.boards[boardID]
threads = {}
for page in JSON.parse e.target.response
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
onSync: (data) ->