aboutsummaryrefslogtreecommitdiff
path: root/src/content/components/common/index.js
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2018-06-17 21:42:52 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2018-06-17 22:04:00 +0900
commit7f56a08f3ba5407e6c8cdec12dc59aa71aa06d03 (patch)
tree3514ba669aabcc77f222fc6bc15f53c1d6982834 /src/content/components/common/index.js
parent48e4bccf0d24bb6ce53c4ecea567ed7750fe8949 (diff)
Use async/await on content script
Diffstat (limited to 'src/content/components/common/index.js')
-rw-r--r--src/content/components/common/index.js13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/content/components/common/index.js b/src/content/components/common/index.js
index 9b7b083..6437011 100644
--- a/src/content/components/common/index.js
+++ b/src/content/components/common/index.js
@@ -44,15 +44,16 @@ export default class Common {
}
}
- reloadSettings() {
- browser.runtime.sendMessage({
- type: messages.SETTINGS_QUERY,
- }).then((settings) => {
+ async reloadSettings() {
+ try {
+ let settings = await browser.runtime.sendMessage({
+ type: messages.SETTINGS_QUERY,
+ });
this.store.dispatch(settingActions.set(settings));
- }).catch((e) => {
+ } catch (e) {
// Sometime sendMessage fails when background script is not ready.
console.warn(e);
setTimeout(() => this.reloadSettings(), 500);
- });
+ }
}
}