From 4f7e2b953fbab58317fb6083619200d9cce4e276 Mon Sep 17 00:00:00 2001 From: jojobyte <184880+jojobyte@users.noreply.github.com> Date: Thu, 31 Oct 2024 18:05:29 -0600 Subject: [PATCH] fix: :bug: missing aliases data & contactsList component --- src/components/crowdnode-card.js | 2 +- src/main.js | 2 ++ src/models/contacts.js | 20 +------------------- src/state/index.js | 10 ++++++++-- src/utils/dash/local.js | 21 ++++++++++++++++++++- src/utils/dash/network.js | 6 ++++-- 6 files changed, 36 insertions(+), 25 deletions(-) diff --git a/src/components/crowdnode-card.js b/src/components/crowdnode-card.js index b04a355..5f4c44b 100644 --- a/src/components/crowdnode-card.js +++ b/src/components/crowdnode-card.js @@ -237,7 +237,7 @@ export const CrowdNodeCard = (() => { this.elements.form.name = this.slugs.form this.elements.form.innerHTML = this.markup.content() - console.log('CN Card render', this.stage, this.elements.form.innerHTML) + console.log('CN Card render', this.stage) this.elements.form.addEventListener( 'submit', diff --git a/src/main.js b/src/main.js index ae0f27c..8e1be77 100644 --- a/src/main.js +++ b/src/main.js @@ -62,6 +62,7 @@ import { import { appDialogs, + appComponents, appState, appTools, userInfo, @@ -241,6 +242,7 @@ let contactsList = await setupContactsList( }, } ) +appComponents.contactsList = contactsList let transactionsList = await setupTransactionsList(mainAppGrid, { events: { diff --git a/src/models/contacts.js b/src/models/contacts.js index 27fd2eb..2870c08 100644 --- a/src/models/contacts.js +++ b/src/models/contacts.js @@ -17,6 +17,7 @@ import { import { getUniqueAlias, + getContactAliases, deriveWalletData, batchGenAcctAddrs, parseAddressField, @@ -24,25 +25,6 @@ import { // Create & Update Contact -export function getContactAliases( - direction // 'outgoing' | 'incoming' -) { - if (!direction) { - return appState.contacts - .filter( - c => c.alias - ) - .map(contact => contact.alias) - } - - return appState.contacts - .filter( - c => c.alias && - !isEmpty(c[direction]) - ) - .map(contact => contact.alias) -} - export async function parseContactURI(uri) { let data = { uri, diff --git a/src/state/index.js b/src/state/index.js index a05c933..1df1a11 100644 --- a/src/state/index.js +++ b/src/state/index.js @@ -64,6 +64,12 @@ export const appDialogs = envoy( }, ) +export const appComponents = envoy( + { + contactsList: {}, + }, +) + export const appState = envoy( { phrase: null, @@ -97,11 +103,11 @@ export const userInfo = envoy( state[prop] !== oldState[prop] && appState.selectedAlias ) { - let decryptedAlias = await appTools.storedData.decryptItem( + let decryptedAlias = await appTools.storedData?.decryptItem?.( store.aliases, appState.selectedAlias, ) - appTools.storedData.encryptItem( + appTools.storedData?.encryptItem?.( store.aliases, appState.selectedAlias, { diff --git a/src/utils/dash/local.js b/src/utils/dash/local.js index 86394fa..f0cf2ce 100644 --- a/src/utils/dash/local.js +++ b/src/utils/dash/local.js @@ -27,12 +27,12 @@ import { } from '../cryptic.js' import { - appState, appTools, appDialogs, } from '../../store/index.js' import { + appState, getStoredWallet, userInfo, } from '../../state/index.js' @@ -1509,3 +1509,22 @@ export async function getUserInfo() { }) } } + +export function getContactAliases( + direction // 'outgoing' | 'incoming' +) { + if (!direction) { + return appState.contacts + .filter( + c => c.alias + ) + .map(contact => contact.alias) + } + + return appState.contacts + .filter( + c => c.alias && + !isEmpty(c[direction]) + ) + .map(contact => contact.alias) +} diff --git a/src/utils/dash/network.js b/src/utils/dash/network.js index 82f73c9..a94154a 100644 --- a/src/utils/dash/network.js +++ b/src/utils/dash/network.js @@ -12,6 +12,7 @@ import { import { walletFunds, userInfo, + appComponents, } from '../../state/index.js' import { @@ -39,6 +40,7 @@ import { parseAddressField, getUniqueAlias, sortAddrs, + getContactAliases, } from './local.js' let defaultSocketEvents = { @@ -763,7 +765,7 @@ export async function processURI(state, target, value) { } let preferredAlias = await getUniqueAlias( - aliases, + getContactAliases(), preferred_username ) @@ -904,7 +906,7 @@ export async function processURI(state, target, value) { if (res) { appState.contacts = res - return contactsList.restate({ + return appComponents.contactsList?.restate?.({ contacts: res, userInfo, })