diff --git a/src/databoard.coffee b/src/databoard.coffee index 3323ac97d..26743c68f 100644 --- a/src/databoard.coffee +++ b/src/databoard.coffee @@ -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) ->