#1254 FIX no tab with id

This commit is contained in:
Grzegorz Zając 2023-09-12 18:57:12 +02:00
parent f932c90b67
commit eb36723fcc
4 changed files with 12 additions and 1 deletions

View File

@ -25,6 +25,8 @@
"errorStorageCorruptedMessage": "We will try to fix it for you. Please wait.", "errorStorageCorruptedMessage": "We will try to fix it for you. Please wait.",
"errorInactiveTabTitle": "Inactive tab", "errorInactiveTabTitle": "Inactive tab",
"errorInactiveTabMessage": "Please refresh this tab to use the 2FAS Browser Extension.", "errorInactiveTabMessage": "Please refresh this tab to use the 2FAS Browser Extension.",
"errorLackOfTabTitle": "Your tab has been closed",
"errorLackOfTabMessage": "The request will be ignored",
"warningTooSoonTitle": "Wait a moment", "warningTooSoonTitle": "Wait a moment",
"warningTooSoonMessage": "Please wait DIFF seconds before sending another request.", "warningTooSoonMessage": "Please wait DIFF seconds before sending another request.",
"warningSelectInputTitle": "Select the text field first", "warningSelectInputTitle": "Select the text field first",

View File

@ -44,6 +44,11 @@ const handleLoginRequest = (tabID, data) => {
}) })
.then(() => closeRequest(tabID, data.token_request_id)) .then(() => closeRequest(tabID, data.token_request_id))
.catch(async err => { .catch(async err => {
if (err.toString().includes('No tab with id')) {
return closeRequest(tabID, data.token_request_id)
.then(() => TwoFasNotification.show(config.Texts.Error.LackOfTab, tabID));
}
await storeLog('error', 8, err, 'handleLoginRequest'); await storeLog('error', 8, err, 'handleLoginRequest');
return TwoFasNotification.show(config.Texts.Error.UndefinedError, tabID); return TwoFasNotification.show(config.Texts.Error.UndefinedError, tabID);
}); });

View File

@ -30,7 +30,7 @@ const closeRequest = async (tabID, requestID) => {
return storeLog('error', 30, err); return storeLog('error', 30, err);
} }
if (!storage || !storage[`tabData-${tabID}`].requestID || requestID !== storage[`tabData-${tabID}`].requestID) { if (!storage || !storage[`tabData-${tabID}`]?.requestID || requestID !== storage[`tabData-${tabID}`]?.requestID) {
return false; return false;
} }

View File

@ -80,6 +80,10 @@ const config = {
InactiveTab: { InactiveTab: {
Title: browser.i18n.getMessage('errorInactiveTabTitle') || t.errorInactiveTabTitle, Title: browser.i18n.getMessage('errorInactiveTabTitle') || t.errorInactiveTabTitle,
Message: browser.i18n.getMessage('errorInactiveTabMessage') || t.errorInactiveTabMessage Message: browser.i18n.getMessage('errorInactiveTabMessage') || t.errorInactiveTabMessage
},
LackOfTab: {
Title: browser.i18n.getMessage('errorLackOfTabTitle') || t.errorLackOfTabTitle,
Message: browser.i18n.getMessage('errorLackOfTabMessage') || t.errorLackOfTabMessage
} }
}, },
Warning: { Warning: {