Fix: bump db-to-cloud, show detailed LockError

This commit is contained in:
eight04 2021-12-08 19:35:17 +08:00
parent 50185be40b
commit 8731be73c0
2 changed files with 17 additions and 0 deletions

View File

@ -1669,6 +1669,14 @@
"message": "Sync failed.\nTry to re-login in Stylus options:\nclick 'disconnect' first, then 'connect'.",
"description": "Tooltip for the toolbar icon"
},
"syncErrorLock": {
"message": "The database is already in used. The lock will expire at $TIME$",
"placeholders": {
"time": {
"content": "$1"
}
}
},
"syncStorageErrorSaving": {
"message": "The value cannot be saved. Try reducing the amount of text.",
"description": "Displayed when trying to save an excessively big value via storage.sync API"

View File

@ -154,6 +154,7 @@ const syncMan = (() => {
status.errorMessage = null;
lastError = null;
} catch (err) {
err.message = translateErrorMessage(err);
status.errorMessage = err.message;
lastError = err;
if (isScheduled &&
@ -208,6 +209,7 @@ const syncMan = (() => {
setState(drive, state) {
return chromeLocal.setValue(STORAGE_KEY + drive.name, state);
},
retryMaxAttempts: 0,
});
}
@ -260,5 +262,12 @@ const syncMan = (() => {
});
}
function translateErrorMessage(err) {
if (err.name === 'LockError') {
return browser.i18n.getMessage('syncErrorLock', new Date(err.expire).toLocaleString([], {timeStyle: 'short'}));
}
return err.message || String(err);
}
//#endregion
})();