From 375c7b7dd0bf5d3a0e2adbe66a646cc7118c1b69 Mon Sep 17 00:00:00 2001 From: Rustem Mussabekov Date: Mon, 6 Nov 2023 16:47:21 +0300 Subject: [PATCH] Do not retry update requests --- src/data/modules/api.js | 11 ++++++----- src/routes/extension/tabs/useSubmit.js | 14 ++++++++------ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/data/modules/api.js b/src/data/modules/api.js index 0df5b8ce..f07ae3e2 100755 --- a/src/data/modules/api.js +++ b/src/data/modules/api.js @@ -9,7 +9,7 @@ import { import ApiError from './error' function* get(url, overrideOptions={}) { - const res = yield req(url, overrideOptions) + const res = yield req(url, overrideOptions, API_RETRIES) var json = {} if (res.headers){ @@ -99,7 +99,7 @@ function* del(url, data={}, options={}) { return json; } -function* req(url, options={}) { +function* req(url, options={}, retries=0) { var finalURL = API_ENDPOINT_URL + url if (url.indexOf('/') == 0) @@ -109,7 +109,8 @@ function* req(url, options={}) { let errorMessage = 'failed to load' - for(let i = 0; i < API_RETRIES; i++){ + for(let i = 0; i <= retries; i++){ + console.log(i, retries) try{ const winner = yield race({ req: call(fetchWrap, finalURL, {...defaultOptions, ...options}), @@ -127,8 +128,8 @@ function* req(url, options={}) { if (e && e.status && e.status >= 400 && e.status < 500) break; //retry - else if(i < API_RETRIES-1) { - yield delay(100 + (API_RETRIES * 100) ); //stop 100ms and try again + else if(i < retries-1) { + yield delay(100 + (retries * 100) ); //stop 100ms and try again } } } diff --git a/src/routes/extension/tabs/useSubmit.js b/src/routes/extension/tabs/useSubmit.js index 4eb29add..af9b0616 100644 --- a/src/routes/extension/tabs/useSubmit.js +++ b/src/routes/extension/tabs/useSubmit.js @@ -16,12 +16,14 @@ export default function ExtensionTabsSubmit({ tabs, collectionId, tags, close }) //save dispatch( manyCreate( - tabs.map(({title, url})=>({ - title, - link: url, - collectionId, - tags - })), + tabs + .reverse() //make sure first is first + .map(({title, url})=>({ + title, + link: url, + collectionId, + tags + })), async()=>{ if (close) await browser.tabs.remove(tabs.map(({id})=>id))