Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

Commit

Permalink
fix: await for settings
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomrdias committed Oct 28, 2022
1 parent bc9de50 commit f8ca296
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/commands/delegations/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ import { buildSimpleConsoleTable } from '../../utils.js'
const handler = async ({ profile }) => {
const client = getClient(profile)
const id = await client.account()
const selected = client.settings.get('delegation')
const delegations = client.settings.get('delegations')
const settings = await client.settings
const selected = settings.get('delegation')
const delegations = settings.get('delegations')

const table = buildSimpleConsoleTable(['selected', 'alias', 'did'])
for (const [did, del] of Object.entries(delegations)) {
Expand Down
10 changes: 6 additions & 4 deletions src/commands/delegations/switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import listAccounts from './list.js'
*/
const handler = async ({ did, alias, profile }) => {
const client = getClient(profile)
const delegations = client.settings.get('delegations')
const settings = await client.settings
const delegations = settings.get('delegations')
if (!delegations) {
console.log('No delegations.')
return
Expand All @@ -38,7 +39,7 @@ const handler = async ({ did, alias, profile }) => {
const found = choices.find((x) => x.alias == alias)
if (found) {
const del = found.value
client.settings.set('delegation', del)
settings.set('delegation', del)
console.log(`now using account: ${del}`)
} else {
console.log(
Expand All @@ -59,18 +60,19 @@ const handler = async ({ did, alias, profile }) => {
* @param {any} client
*/
async function inquirerPick(choices, client) {
const settings = await client.settings
await inquirer
.prompt([
{
type: 'list',
name: 'Choose an account',
choices,
default: client.settings.get('delegation'),
default: settings.get('delegation'),
},
])
.then((answers) => {
const del = answers['Choose an account']
client.settings.set('delegation', del)
settings.set('delegation', del)
console.log(`now using account: ${del}`)
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/settings/reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ const handler = async (args) => {
type: 'confirm',
default: false,
})

const settings = await client.settings
if (reset) {
client.settings.clear()
settings.clear()
view.succeed('Settings cleared.')
} else {
view.info('exiting')
Expand Down

0 comments on commit f8ca296

Please sign in to comment.