Update the badge icon if the backend experiences an error (#602)

This commit is contained in:
toasted-nutbread 2020-06-13 10:20:12 -04:00 committed by GitHub
parent 8bc15e60b5
commit 5cba421201
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -168,6 +168,8 @@ class Backend {
}, 1000);
this._updateBadge();
yomichan.on('log', this._onLog.bind(this));
await this.environment.prepare();
await this.database.prepare();
await this.translator.prepare();
@ -316,6 +318,14 @@ class Backend {
chrome.tabs.sendMessage(tabId, {action: 'zoomChanged', params: {oldZoomFactor, newZoomFactor}}, callback);
}
_onLog({level}) {
const levelValue = this._getErrorLevelValue(level);
if (levelValue <= this._getErrorLevelValue(this._logErrorLevel)) { return; }
this._logErrorLevel = level;
this._updateBadge();
}
applyOptions() {
const options = this.getOptions(this.optionsContext);
this._updateBadge();
@ -809,12 +819,6 @@ class Backend {
_onApiLog({error, level, context}) {
yomichan.log(jsonToError(error), level, context);
const levelValue = this._getErrorLevelValue(level);
if (levelValue <= this._getErrorLevelValue(this._logErrorLevel)) { return; }
this._logErrorLevel = level;
this._updateBadge();
}
_onApiLogIndicatorClear() {