diff --git a/_locales/en/messages.json b/_locales/en/messages.json index be2006e4..0f8c309b 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -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" diff --git a/background/sync-manager.js b/background/sync-manager.js index 21a644c7..94f80c13 100644 --- a/background/sync-manager.js +++ b/background/sync-manager.js @@ -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 })();