diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-03-10 20:26:57 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-10 20:26:57 -0500 |
commit | 63de9273b383cc46a2f063cfb40ef4699b06e612 (patch) | |
tree | cdaefbed8c8c450c20c29a8fb699275947bd5e17 /ext/js/pages | |
parent | b1f96a7ca7c37d9269b59d14b2cd67cc21db4d13 (diff) |
Fix permissions changes not being supported on some browsers (#1513)
Diffstat (limited to 'ext/js/pages')
-rw-r--r-- | ext/js/pages/settings/settings-controller.js | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/ext/js/pages/settings/settings-controller.js b/ext/js/pages/settings/settings-controller.js index 4a86470d..5fa5b660 100644 --- a/ext/js/pages/settings/settings-controller.js +++ b/ext/js/pages/settings/settings-controller.js @@ -51,8 +51,10 @@ class SettingsController extends EventDispatcher { prepare() { yomichan.on('optionsUpdated', this._onOptionsUpdated.bind(this)); - chrome.permissions.onAdded.addListener(this._onPermissionsChanged.bind(this)); - chrome.permissions.onRemoved.addListener(this._onPermissionsChanged.bind(this)); + if (this._canObservePermissionsChanges()) { + chrome.permissions.onAdded.addListener(this._onPermissionsChanged.bind(this)); + chrome.permissions.onRemoved.addListener(this._onPermissionsChanged.bind(this)); + } } async refresh() { @@ -206,4 +208,8 @@ class SettingsController extends EventDispatcher { const permissions = await this._permissionsUtil.getAllPermissions(); this.trigger(event, {permissions}); } + + _canObservePermissionsChanges() { + return isObject(chrome.permissions) && isObject(chrome.permissions.onAdded) && isObject(chrome.permissions.onRemoved); + } } |