Skip to content

Commit

Permalink
fix: make the functions that are without any promises sync
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Mar 24, 2021
1 parent 7f9a5a3 commit 09a6cc2
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/toggle-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ export default class ToggleProviders {
}),
)
}
async getItems(): Promise<Array<string>> {
getItems(): Array<string> {
if (this.action === 'disable') {
return this.providers.filter(name => !this.disabledProviders.includes(name))
}
return this.disabledProviders
}
async process(name: string): Promise<void> {
process(name: string): void {
if (this.action === 'disable') {
this.disabledProviders.push(name)
this.emitter.emit('did-disable', name)
Expand All @@ -40,22 +40,25 @@ export default class ToggleProviders {
}
atom.config.set('linter.disabledProviders', this.disabledProviders)
}
async show() {
show() {
if (!SelectListView) {
SelectListView = require('atom-select-list')
}
const selectListView = new SelectListView({
items: await this.getItems(),
items: this.getItems(),
emptyMessage: 'No matches found',
elementForItem: (item: any) => {
const li = document.createElement('li')
li.textContent = item
return li
},
didConfirmSelection: (item: any) => {
this.process(item)
.catch(e => console.error('[Linter] Unable to process toggle:', e))
.then(() => this.dispose())
try {
this.process(item)
this.dispose()
} catch(e) {
console.error('[Linter] Unable to process toggle:', e)
}
},
didCancelSelection: () => {
this.dispose()
Expand Down

0 comments on commit 09a6cc2

Please sign in to comment.