diff --git a/src/components/contacts-list.js b/src/components/contacts-list.js
index 06e7b00..8b2f842 100644
--- a/src/components/contacts-list.js
+++ b/src/components/contacts-list.js
@@ -38,13 +38,13 @@ const initialState = {
`,
- content: state => html`
+ content: async state => html`
${state.header(state)}
${
state.contacts.length > 0
- ? state.contacts.map(c => state.item(c)).join('')
+ ? (await Promise.all(state.contacts.map(async c => await state.item(c)))).join('')
: ''
}
${
@@ -55,7 +55,7 @@ const initialState = {
${state.footer(state)}
`,
- item: c => {
+ item: async c => {
// console.warn('contact list item', c)
if ('string' === typeof c) {
return html`
@@ -109,7 +109,7 @@ const initialState = {
return html`
- ${getAvatar(c)}
+ ${await getAvatar(c)}
${itemAlias}
${itemName}
@@ -181,7 +181,7 @@ export async function setupContactsList(
section.id = state.slugs.section
section.classList.add(state.placement || '')
- section.innerHTML = state.content(state)
+ section.innerHTML = await state.content(state)
function addListener(
node,
@@ -228,7 +228,7 @@ export async function setupContactsList(
await restate(state, renderState)
section.id = state.slugs.section
- section.innerHTML = state.content(state)
+ section.innerHTML = await state.content(state)
removeAllListeners()
addListeners()
diff --git a/src/components/dialog.js b/src/components/dialog.js
index 4882d29..f116689 100644
--- a/src/components/dialog.js
+++ b/src/components/dialog.js
@@ -1,5 +1,14 @@
import { lit as html } from '../helpers/lit.js'
-import { formDataEntries } from '../helpers/utils.js'
+import {
+ formDataEntries,
+ envoy,
+} from '../helpers/utils.js'
+
+let modal = envoy(
+ {
+ rendered: {},
+ },
+)
let _handlers = []
@@ -13,6 +22,7 @@ const initialState = {
closeTxt: 'X',
closeAlt: `Close`,
placement: 'center',
+ modal,
rendered: null,
responsive: true,
delay: 500,
@@ -28,7 +38,7 @@ const initialState = {
}
`,
- content: state => html`
+ content: async state => html`
${state.header(state)}
`
}
diff --git a/src/main.js b/src/main.js
index 57020a3..026aac0 100644
--- a/src/main.js
+++ b/src/main.js
@@ -185,7 +185,7 @@ let contactsList = await setupContactsList(
if (!contactData.outgoing) {
// Finish Pairing
let contactName = contactData?.info?.name || 'Contact'
- appDialogs.addContact.render(
+ await appDialogs.addContact.render(
{
name: `Finish Pairing with ${contactName}`,
wallet: shareAccount,
@@ -197,7 +197,7 @@ let contactsList = await setupContactsList(
appDialogs.addContact.showModal()
} else {
// Edit Contact
- appDialogs.editContact.render(
+ await appDialogs.editContact.render(
{
wallet,
account: appState.account,
@@ -301,7 +301,7 @@ let contactsList = await setupContactsList(
appState.contacts.push(newContact)
- contactsList.render(
+ await contactsList.render(
appState.contacts.sort(sortContactsByAlias)
)
@@ -311,7 +311,7 @@ let contactsList = await setupContactsList(
)
}
- appDialogs.addContact.render(
+ await appDialogs.addContact.render(
{
name: 'Add a New Contact',
wallet: shareAccount,
@@ -394,90 +394,90 @@ async function main() {
}
)
- appDialogs.walletEncrypt = walletEncryptRig({
+ appDialogs.walletEncrypt = await walletEncryptRig({
setupDialog, appDialogs, appState, mainApp,
wallet, wallets, bodyNav, dashBalance,
})
- appDialogs.walletDecrypt = walletDecryptRig({
+ appDialogs.walletDecrypt = await walletDecryptRig({
setupDialog, appDialogs, appState, mainApp, importFromJson,
wallets, decryptKeystore, getUserInfo, store, deriveWalletData,
})
- appDialogs.walletBackup = walletBackupRig({
+ appDialogs.walletBackup = await walletBackupRig({
mainApp, wallet, wallets, setupDialog, appDialogs, appState, store,
exportWalletData, saveJsonToFile, localForageBaseCfg,
})
- appDialogs.phraseBackup = phraseBackupRig({
+ appDialogs.phraseBackup = await phraseBackupRig({
mainApp, wallets, setupDialog, appDialogs,
})
- appDialogs.phraseGenerate = phraseGenerateRig({
+ appDialogs.phraseGenerate = await phraseGenerateRig({
setupDialog, appDialogs, appState,
mainApp, wallet, wallets, store,
deriveWalletData, generateWalletData,
})
- appDialogs.phraseImport = phraseImportRig({
+ appDialogs.phraseImport = await phraseImportRig({
setupDialog, appDialogs, appState, store,
mainApp, wallet, wallets, deriveWalletData,
})
- appDialogs.onboard = onboardRig({
+ appDialogs.onboard = await onboardRig({
mainApp, setupDialog, appDialogs,
})
- appDialogs.addContact = addContactRig({
+ appDialogs.addContact = await addContactRig({
setupDialog, updateAllFunds,
appDialogs, appState, appTools, store, walletFunds,
mainApp, wallet, userInfo, contactsList,
})
- appDialogs.confirmAction = confirmActionRig({
+ appDialogs.confirmAction = await confirmActionRig({
mainApp, setupDialog,
appDialogs, appState, appTools,
})
- appDialogs.confirmDelete = confirmDeleteRig({
+ appDialogs.confirmDelete = await confirmDeleteRig({
mainApp, setupDialog, appDialogs, appState, appTools,
store, userInfo, contactsList,
})
- appDialogs.editContact = editContactRig({
+ appDialogs.editContact = await editContactRig({
setupDialog, updateAllFunds,
appDialogs, appState, appTools, store, walletFunds,
mainApp, wallet, userInfo, contactsList,
})
- appDialogs.editProfile = editProfileRig({
+ appDialogs.editProfile = await editProfileRig({
mainApp, setupDialog, store,
appState, appTools, bodyNav,
})
- appDialogs.scanContact = scanContactRig({
+ appDialogs.scanContact = await scanContactRig({
setupDialog, mainApp,
})
- appDialogs.sendOrReceive = sendOrReceiveRig({
+ appDialogs.sendOrReceive = await sendOrReceiveRig({
mainApp, appDialogs, appState, appTools, store,
wallet, account: appState.account, walletFunds,
setupDialog, deriveWalletData, createTx,
getAddrsWithFunds, batchGenAcctAddrs,
})
- appDialogs.sendConfirm = sendConfirmRig({
+ appDialogs.sendConfirm = await sendConfirmRig({
mainApp, appDialogs, appState, appTools,
store, userInfo, contactsList, walletFunds,
setupDialog, deriveWalletData, getAddrsWithFunds,
createTx, sendTx,
})
- appDialogs.requestQr = requestQrRig({
+ appDialogs.requestQr = await requestQrRig({
mainApp, setupDialog,
})
- appDialogs.pairQr = pairQrRig({
+ appDialogs.pairQr = await pairQrRig({
setupDialog,
mainApp, wallet, userInfo,
})
@@ -500,7 +500,7 @@ async function main() {
name = 'Receive Funds'
}
- appDialogs.sendOrReceive.render({
+ await appDialogs.sendOrReceive.render({
action: fde.intent,
wallet,
account: appState.account,
@@ -593,7 +593,7 @@ async function main() {
) {
sessionStorage.removeItem('encryptionPassword')
- appDialogs.walletDecrypt.render({ wallet })
+ await appDialogs.walletDecrypt.render({ wallet })
await appDialogs.walletDecrypt.showModal()
}
@@ -612,7 +612,7 @@ async function main() {
]
if (!appState.phrase) {
- appDialogs.onboard.render()
+ await appDialogs.onboard.render()
await appDialogs.onboard.show()
} else {
wallet = await deriveWalletData(appState.phrase)
@@ -718,14 +718,13 @@ async function main() {
await getUserInfo()
- appDialogs.editProfile.render(
+ await appDialogs.editProfile.render(
{
wallet,
userInfo,
},
'afterend',
)
-
appDialogs.editProfile.showModal()
}
if (id === 'nav-backup') {
@@ -735,7 +734,7 @@ async function main() {
// @ts-ignore
event.target?.closest?.('menu.user')?.classList?.toggle('hidden')
- appDialogs.walletBackup.render(
+ await appDialogs.walletBackup.render(
{
wallet,
wallets,
@@ -751,7 +750,7 @@ async function main() {
// @ts-ignore
event.target?.closest?.('menu.user')?.classList?.toggle('hidden')
- appDialogs.confirmAction.render({
+ await appDialogs.confirmAction.render({
name: 'Confirm Wallet Lock',
actionTxt: 'Lock it!',
actionAlt: 'Lock the wallet',
@@ -774,7 +773,7 @@ async function main() {
// @ts-ignore
event.target?.closest?.('menu.user')?.classList?.toggle('hidden')
- appDialogs.confirmAction.render({
+ await appDialogs.confirmAction.render({
name: 'Confirm Wallet Disconnect',
actionTxt: 'Disconnect',
actionAlt: 'Clear all wallet data stored in browser',
diff --git a/src/rigs/add-contact.js b/src/rigs/add-contact.js
index 554d2c5..26159ff 100644
--- a/src/rigs/add-contact.js
+++ b/src/rigs/add-contact.js
@@ -22,7 +22,7 @@ import {
ALIAS_REGEX,
} from '../helpers/constants.js'
-export let addContactRig = (function (globals) {
+export let addContactRig = (async function (globals) {
'use strict';
let {
@@ -227,7 +227,7 @@ export let addContactRig = (function (globals) {
return
}
- let addContact = setupDialog(
+ let addContact = await setupDialog(
mainApp,
{
name: 'Add a New Contact',
@@ -494,7 +494,7 @@ export let addContactRig = (function (globals) {
console.log('scanContact', appDialogs.scanContact)
if (fde?.intent === 'scan_new_contact') {
- appDialogs.scanContact.render(
+ await appDialogs.scanContact.render(
{
wallet,
},
diff --git a/src/rigs/confirm-action.js b/src/rigs/confirm-action.js
index 9a0c2d9..a7996ad 100644
--- a/src/rigs/confirm-action.js
+++ b/src/rigs/confirm-action.js
@@ -3,7 +3,7 @@ import {
formDataEntries,
} from '../helpers/utils.js'
-export let confirmActionRig = (function (globals) {
+export let confirmActionRig = (async function (globals) {
'use strict';
let {
@@ -11,7 +11,7 @@ export let confirmActionRig = (function (globals) {
store, userInfo, contactsList,
} = globals
- let confirmAction = setupDialog(
+ let confirmAction = await setupDialog(
mainApp,
{
name: 'Confirm',
diff --git a/src/rigs/confirm-delete.js b/src/rigs/confirm-delete.js
index d2bad60..218a5be 100644
--- a/src/rigs/confirm-delete.js
+++ b/src/rigs/confirm-delete.js
@@ -5,7 +5,7 @@ import {
sortContactsByAlias,
} from '../helpers/utils.js'
-export let confirmDeleteRig = (function (globals) {
+export let confirmDeleteRig = (async function (globals) {
'use strict';
let {
@@ -13,7 +13,7 @@ export let confirmDeleteRig = (function (globals) {
store, userInfo, contactsList,
} = globals
- let confirmDelete = setupDialog(
+ let confirmDelete = await setupDialog(
mainApp,
{
name: 'Confirm Remove',
diff --git a/src/rigs/edit-contact.js b/src/rigs/edit-contact.js
index 9e63048..c13dabe 100644
--- a/src/rigs/edit-contact.js
+++ b/src/rigs/edit-contact.js
@@ -22,7 +22,7 @@ import {
ALIAS_REGEX,
} from '../helpers/constants.js'
-export let editContactRig = (function (globals) {
+export let editContactRig = (async function (globals) {
'use strict';
let {
@@ -89,7 +89,7 @@ export let editContactRig = (function (globals) {
)
}, 1000)
- let editContact = setupDialog(
+ let editContact = await setupDialog(
mainApp,
{
name: 'Edit Contact',
@@ -155,12 +155,12 @@ export let editContactRig = (function (globals) {
`,
- content: state => html`
+ content: async state => html`