Skip to content

Commit aeacb6a

Browse files
committed
Add fallthrough aggregator logic for #316 and #367
1 parent 31ec85c commit aeacb6a

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

mink-plugin/content.js

+10
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ function checkAggregatorHealthAndSet (aggregatorIndex) {
140140

141141
const options = { mode: 'no-cors', signal }
142142

143+
console.log(`Checking the health of aggregator #${aggregatorIndex} at ${memgatorHosts[aggregatorIndex]}`)
144+
143145
return window.fetch(url, options)
144146
.then(setTimeout(() => { aborter.abort(`The request to ${url} timed out and has been aborted`) }, timeout))
145147
.catch(error => {
@@ -326,6 +328,14 @@ function addToIgnorelist (currentIgnorelist, uriIn) {
326328
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
327329
log(`in listener with ${request.method}`)
328330

331+
if (request.method === 'tryNextAggregator') {
332+
++hostI
333+
checkAggregatorHealthAndSet(hostI)
334+
console.log(`trying again with aggregator ${hostI}`)
335+
getMementos(request.uri)
336+
return
337+
}
338+
329339
if (request.method === 'addToIgnorelist') {
330340
getIgnorelist(addToIgnorelist, request.uri) // And add uri
331341
return

mink-plugin/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"content_security_policy": {
5555
"extension_pages": "script-src 'self'; object-src 'self'"
5656
},
57-
"minimum_chrome_version": "88",
57+
"minimum_chrome_version": "99",
5858
"options_ui": {
5959
"page": "options.html",
6060
"open_in_tab": true

mink-plugin/mink.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,6 @@ chrome.runtime.onMessage.addListener(
263263
const resp = await fetch(submissionURI)
264264
changeArchiveIcon(request, response)
265265
})
266-
} else if (request.method === 'tryNextAggregator') {
267-
log('TODO: TRYING NEXT AGGREGATOR')
268266
} else {
269267
log(`Message sent using chrome.runtime not caught: ${request.method}`)
270268
}
@@ -343,10 +341,11 @@ async function fetchTimeMap (uri, tabid) {
343341
logWithTrace('TODO: switch up the aggregator')
344342
} else if (err instanceof SyntaxError) {
345343
logWithTrace("JSON parsing failed, switch up the aggregator")
346-
log(`Previous aggregator: {aggregator}`)
344+
log(`Previous aggregator endpoint: ${uri}`)
347345
chrome.tabs.sendMessage(tabid, {
348-
method: 'tryNextAggregator'
349-
})
346+
method: 'tryNextAggregator',
347+
uri: uri
348+
}, startAgainWithNewAggregatorTempFunctionName)
350349
}
351350
})
352351
/*
@@ -361,6 +360,10 @@ async function fetchTimeMap (uri, tabid) {
361360
*/
362361
}
363362

363+
function startAgainWithNewAggregatorTempFunctionName () {
364+
console.log('repeating query logic with a new aggregator')
365+
}
366+
364367
function setBadgeText (value, tabid) {
365368
let badgeValue = value
366369

0 commit comments

Comments
 (0)