diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-06-13 10:20:12 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-13 10:20:12 -0400 |
commit | 5cba421201b596f4430dd45f3715ad515661b109 (patch) | |
tree | 80e4de5e5433b22362208654642fdf732dc4d9c9 | |
parent | 8bc15e60b55f8a251006ac03e0237420644cf029 (diff) |
Update the badge icon if the backend experiences an error (#602)
-rw-r--r-- | ext/bg/js/backend.js | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index faba6c42..0c7a0301 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -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() { |