From 5eb7808f96cf8a2e372d2f0654bf213d127fbcf9 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 7 Nov 2015 14:18:09 -0800 Subject: [PATCH] Autodetect when board doesn't have archive when cleaning history. #525 Also remove data from any boards that have been deleted. --- src/General/lib/databoard.class | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/General/lib/databoard.class b/src/General/lib/databoard.class index 88494e607..4f7d2a304 100755 --- a/src/General/lib/databoard.class +++ b/src/General/lib/databoard.class @@ -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