diff --git a/src/Linkification/Embedding.coffee b/src/Linkification/Embedding.coffee index 9eb7f6a72..c80a7fa0f 100644 --- a/src/Linkification/Embedding.coffee +++ b/src/Linkification/Embedding.coffee @@ -20,8 +20,6 @@ Embedding = for key, service of Embedding.types when service.title?.batchSize Embedding.flushTitles service.title return - @cache.init Conf['cachedTitles'] - $.sync 'cachedTitles', @cache.sync events: (post) -> return if g.VIEW is 'archive' @@ -108,9 +106,7 @@ Embedding = {key, uid, options, link, post} = data return if not (service = Embedding.types[key].title) $.addClass link, key.toLowerCase() - if (text = Embedding.cache.get data) - Embedding.cb.titleText text, data - else if service.batchSize + if service.batchSize (service.queue or= []).push data if service.queue.length >= service.batchSize Embedding.flushTitles service @@ -126,38 +122,6 @@ Embedding = return CrossOrigin.cache service.api(data.uid for data in queue), cb - cache: do -> - titles = $.dict() - newEntries = [] - init = (data) -> - try - for {key, uid, text} in data - titles["#{key}.#{uid}"] = text - return - sync = (data) -> - try - for {key, uid, text} in data - k = "#{key}.#{uid}" - break if k of titles - titles[k] = text - return - get = ({key, uid}) -> - titles["#{key}.#{uid}"] - set = ({key, uid}, text) -> - titles["#{key}.#{uid}"] = text - newEntries.push {key, uid, text} - save() - save = $.debounce 2 * $.SECOND, -> - $.get 'cachedTitles', Conf['cachedTitles'], ({cachedTitles}) -> - sync cachedTitles - try - cachedTitles = newEntries.concat(cachedTitles)[-100..] - catch - cachedTitles = newEntries - newEntries = [] - $.set 'cachedTitles', cachedTitles - {init, sync, get, set, save} - preview: (data) -> {key, uid, link} = data return if not (service = Embedding.types[key].preview) @@ -215,28 +179,25 @@ Embedding = title: (req, data) -> return unless req.status - {key, uid} = data + {key, uid, options, link, post} = data {status} = req service = Embedding.types[key].title - switch status + text = "[#{key}] #{switch status when 200, 304 text = service.text req.response, uid if typeof text is 'string' - Embedding.cache.set data, text + text else text = link.textContent when 404 - text = "Not Found" + "Not Found" when 403 - text = "Forbidden or Private" + "Forbidden or Private" else - text = "#{status}'d" - Embedding.cb.titleText text, data + "#{status}'d" + }" - titleText: (text, data) -> - {key, link, post} = data - text = "[#{key}] #{text}" link.dataset.original = link.textContent link.textContent = text for post2 in post.clones diff --git a/src/config/Config.coffee b/src/config/Config.coffee index e2e2099ff..798b2f449 100644 --- a/src/config/Config.coffee +++ b/src/config/Config.coffee @@ -1176,8 +1176,6 @@ Config = knownBanners: '<%= readJSON("banners.json").join(",") %>' - cachedTitles: [[]] - passMessageClosed: false 'Prerequest Captcha': false