Skip to content

Commit

Permalink
more async/await migration
Browse files Browse the repository at this point in the history
  • Loading branch information
maciekmm committed Oct 22, 2019
1 parent 7454af1 commit d23422f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 30 deletions.
41 changes: 13 additions & 28 deletions src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,21 @@ const defaults = {
theme: 'dark'
}

export function getSidebarAction() {
return new Promise((resolve, reject) => {
browser.commands.getAll().then(cmds => {
let filtered = cmds.filter(e => e.name === "_execute_sidebar_action")
if (filtered.length == 1) {
resolve(filtered[0])
return
}
reject('no actions found')
})
})
export async function getSidebarAction() {
return (await browser.commands.getAll())
.filter(e => e.name === '_execute_sidebar_action')[0]
}

export function getConfig() {
return new Promise((resolve, reject) => {
browser.storage.local.get().then(c => {
for (let key in defaults) {
if (!(key in c)) {
c[key] = defaults[key]
}
}
getSidebarAction().then(action => {
c['shortcut'] = action.shortcut
resolve(c)
}, err => {
console.error('error occured while getting sidebar actions', err)
resolve(c)
})
})
})
export async function getConfig() {
let cfg = await browser.storage.local.get()
for (let key in defaults) {
if (!(key in cfg)) {
cfg[key] = defaults[key]
}
}
let sidebarAction = await getSidebarAction()
cfg['shortcut'] = sidebarAction.shortcut
return cfg
}

var sessionStorage;
Expand Down
1 change: 0 additions & 1 deletion src/sidebar/sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<body>
<header>
<ul id="pinned-tabs">

</ul>
</header>
<main>
Expand Down
1 change: 0 additions & 1 deletion src/sidebar/tab/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export default class ContainerTab {
init() {
this._createElements()
this.render()


browser.tabs.onUpdated.addListener(this._listeners.update = (id, change, tab) => {
this.tab = tab
Expand Down

0 comments on commit d23422f

Please sign in to comment.