diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2018-06-17 20:21:39 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2018-06-17 21:55:25 +0900 |
commit | 48e4bccf0d24bb6ce53c4ecea567ed7750fe8949 (patch) | |
tree | 7c16a68489f2894564da18ae059ba492db88907a /src/background/components/indicator.js | |
parent | 88238005ab64f957d9def8c18473d8210b280de9 (diff) |
Use async/await on background
Diffstat (limited to 'src/background/components/indicator.js')
-rw-r--r-- | src/background/components/indicator.js | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/background/components/indicator.js b/src/background/components/indicator.js index cceb119..1ded329 100644 --- a/src/background/components/indicator.js +++ b/src/background/components/indicator.js @@ -8,19 +8,17 @@ export default class IndicatorComponent { messages.onMessage(this.onMessage.bind(this)); browser.browserAction.onClicked.addListener(this.onClicked); - browser.tabs.onActivated.addListener((info) => { - return browser.tabs.query({ currentWindow: true }).then(() => { - return this.onTabActivated(info); - }); + browser.tabs.onActivated.addListener(async(info) => { + await browser.tabs.query({ currentWindow: true }); + return this.onTabActivated(info); }); } - onTabActivated(info) { - return browser.tabs.sendMessage(info.tabId, { + async onTabActivated(info) { + let { enabled } = await browser.tabs.sendMessage(info.tabId, { type: messages.ADDON_ENABLED_QUERY, - }).then((resp) => { - return this.updateIndicator(resp.enabled); }); + return this.updateIndicator(enabled); } onClicked(tab) { |