Use async/await on content script
This commit is contained in:
parent
48e4bccf0d
commit
7f56a08f3b
3 changed files with 32 additions and 34 deletions
|
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue