From aca7ed0a550ecab4bcc38d13c09b2e5da115155c Mon Sep 17 00:00:00 2001 From: ccd0 Date: Thu, 12 Dec 2019 18:40:05 -0800 Subject: [PATCH] Don't prune data for threads on kissu.moe while they're in the archive. --- src/classes/DataBoard.coffee | 17 +++++++++++++---- src/platform/$.coffee | 4 ++-- src/site/SW.tinyboard.coffee | 5 +++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/classes/DataBoard.coffee b/src/classes/DataBoard.coffee index 2e76d1413..9acb504bb 100644 --- a/src/classes/DataBoard.coffee +++ b/src/classes/DataBoard.coffee @@ -138,11 +138,20 @@ class DataBoard $.cache threadsList, -> return unless @status is 200 archiveList = g.SITE.urls.archiveListJSON?({siteID, boardID}) - return that.ajaxCleanParse(boardID, @response) unless archiveList + archiveListHTML = g.SITE.urls.archive?({siteID, boardID}) response1 = @response - $.cache archiveList, -> - return unless @status is 200 - that.ajaxCleanParse(boardID, response1, @response) + if archiveList + $.cache archiveList, -> + return unless @status is 200 + that.ajaxCleanParse(boardID, response1, @response) + else if g.SITE.archiveListParse and archiveListHTML + $.cache archiveListHTML, -> + return unless @status is 200 or @status is 404 + response2 = if @status is 404 then [] else g.SITE.archiveListParse(@response) + that.ajaxCleanParse(boardID, response1, response2) + , {responseType: 'document'} + else + that.ajaxCleanParse(boardID, @response) ajaxCleanParse: (boardID, response1, response2) -> siteID = g.SITE.ID diff --git a/src/platform/$.coffee b/src/platform/$.coffee index e0df4ecb3..f7c7513dd 100644 --- a/src/platform/$.coffee +++ b/src/platform/$.coffee @@ -208,7 +208,7 @@ $.whenModified = (url, bucket, cb, options={}) -> do -> reqs = $.dict() $.cache = (url, cb, options={}) -> - {ajax} = options + {ajax, responseType} = options if (req = reqs[url]) if req.callbacks req.callbacks.push cb @@ -221,7 +221,7 @@ do -> for cb in @callbacks do (cb) => $.queueTask => cb.call @, {isCached: false} delete @callbacks - req = (ajax or $.ajax) url, {onloadend} + req = (ajax or $.ajax) url, {onloadend, responseType} req.callbacks = [cb] reqs[url] = req $.cleanCache = (testf) -> diff --git a/src/site/SW.tinyboard.coffee b/src/site/SW.tinyboard.coffee index 2d43c0654..2e1496631 100644 --- a/src/site/SW.tinyboard.coffee +++ b/src/site/SW.tinyboard.coffee @@ -45,6 +45,7 @@ SW.tinyboard = post: ({postID}) -> "##{postID}" index: ({siteID, boardID}) -> "#{Conf['siteProperties'][siteID]?.root or "http://#{siteID}/"}#{boardID}/" catalog: ({siteID, boardID}) -> "#{Conf['siteProperties'][siteID]?.root or "http://#{siteID}/"}#{boardID}/catalog.html" + archive: ({siteID, boardID}) -> "#{Conf['siteProperties'][siteID]?.root or "http://#{siteID}/"}#{boardID}/archive/" threadJSON: ({siteID, boardID, threadID}) -> root = Conf['siteProperties'][siteID]?.root if root then "#{root}#{boardID}/res/#{threadID}.json" else '' @@ -107,6 +108,7 @@ SW.tinyboard = nav: prev: '.pages > form > [value=Previous]' next: '.pages > form > [value=Next]' + archiveThreadID: '#archive-list td:first-of-type' classes: highlight: 'highlighted' @@ -206,3 +208,6 @@ SW.tinyboard = catalogPin: (threadRoot) -> threadRoot.dataset.sticky = 'true' + + archiveListParse: (response) -> + $$(SW.tinyboard.selectors.archiveThreadID, response).map((x) -> +x.textContent)