8.0.0 #3

Merged
wanhose merged 30 commits from v8.0.0 into main 2024-10-15 15:01:19 +00:00
Showing only changes of commit d89b1c6c08 - Show all commits

View File

@ -202,9 +202,11 @@ function matchToPattern(match) {
/**
* @async
* @description Refresh data
* @param {number} [attempt]
* @returns {Promise<void>}
*/
async function refreshData() {
async function refreshData(attempt = 1) {
if (attempt <= 3) {
try {
const { data } = await requestManager.fetch(`${apiUrl}/data/`);
@ -212,7 +214,8 @@ async function refreshData() {
return data;
} catch {
return await refreshData();
return await refreshData(attempt + 1);
}
}
}
@ -220,9 +223,11 @@ async function refreshData() {
* @async
* @description Refresh issues for the given hostname
* @param {string} hostname
* @param {number} [attempt]
* @returns {Promise<ExtensionIssue | undefined>}
*/
async function refreshIssue(hostname) {
async function refreshIssue(hostname, attempt = 1) {
if (attempt <= 3) {
try {
const { data } = await requestManager.fetch(`${apiUrl}/issues/${hostname}/`);
@ -232,13 +237,18 @@ async function refreshIssue(hostname) {
return undefined;
}
const issue = { expiresIn: Date.now() + 4 * 60 * 60 * 1000, flags: data.flags, url: data.url };
const issue = {
expiresIn: Date.now() + 4 * 60 * 60 * 1000,
flags: data.flags,
url: data.url,
};
await updateStore(hostname, { issue });
return data;
} catch {
return await refreshData();
return await refreshIssue(hostname, attempt + 1);
}
}
}