From 4c329af6e0bfdc6610e25196c0b0cd5005d95f65 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 9 Mar 2019 00:06:51 -0800 Subject: [PATCH] Remove event from $.cache interface. --- src/classes/Fetcher.coffee | 10 ++++++---- src/platform/$.coffee | 7 +++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/classes/Fetcher.coffee b/src/classes/Fetcher.coffee index 1e144c68b..b130c36a3 100644 --- a/src/classes/Fetcher.coffee +++ b/src/classes/Fetcher.coffee @@ -15,8 +15,9 @@ class Fetcher @root.textContent = "Loading post No.#{@postID}..." if @threadID - $.cache "#{location.protocol}//a.4cdn.org/#{@boardID}/thread/#{@threadID}.json", (e, isCached) => - @fetchedPost e.target, isCached + that = @ + $.cache "#{location.protocol}//a.4cdn.org/#{@boardID}/thread/#{@threadID}.json", ({isCached}) -> + that.fetchedPost @, isCached else @archivedPost() @@ -80,8 +81,9 @@ class Fetcher if isCached api = "#{location.protocol}//a.4cdn.org/#{@boardID}/thread/#{@threadID}.json" $.cleanCache (url) -> url is api - $.cache api, (e) => - @fetchedPost e.target, false + that = @ + $.cache api, -> + that.fetchedPost @, false return # The post can be deleted by the time we check a quote. diff --git a/src/platform/$.coffee b/src/platform/$.coffee index abb6f28bc..9b95c49ae 100644 --- a/src/platform/$.coffee +++ b/src/platform/$.coffee @@ -87,7 +87,7 @@ do -> $.cache = (url, cb, options) -> if req = reqs[url] if req.readyState is 4 - $.queueTask -> cb.call req, req.evt, true + $.queueTask -> cb.call req, {isCached: true} else req.callbacks.push cb return req @@ -96,10 +96,9 @@ do -> return if not (req = $.ajax url, options) catch err return - $.on req, 'load', (e) -> - @evt = e + $.on req, 'load', -> for cb in @callbacks - do (cb) => $.queueTask => cb.call @, e, false + do (cb) => $.queueTask => cb.call @, {isCached: false} delete @callbacks $.on req, 'abort error', rm req.callbacks = [cb]