Skip to content

Commit

Permalink
fix: 🐛 missing aliases data & contactsList component
Browse files Browse the repository at this point in the history
  • Loading branch information
jojobyte committed Nov 1, 2024
1 parent 76a8c2f commit 4f7e2b9
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/components/crowdnode-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import {

import {
appDialogs,
appComponents,
appState,
appTools,
userInfo,
Expand Down Expand Up @@ -241,6 +242,7 @@ let contactsList = await setupContactsList(
},
}
)
appComponents.contactsList = contactsList

let transactionsList = await setupTransactionsList(mainAppGrid, {
events: {
Expand Down
20 changes: 1 addition & 19 deletions src/models/contacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,14 @@ import {

import {
getUniqueAlias,
getContactAliases,
deriveWalletData,
batchGenAcctAddrs,
parseAddressField,
} from '../utils/dash/local.js'

// 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,
Expand Down
10 changes: 8 additions & 2 deletions src/state/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ export const appDialogs = envoy(
},
)

export const appComponents = envoy(
{
contactsList: {},
},
)

export const appState = envoy(
{
phrase: null,
Expand Down Expand Up @@ -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,
{
Expand Down
21 changes: 20 additions & 1 deletion src/utils/dash/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ import {
} from '../cryptic.js'

import {
appState,
appTools,
appDialogs,
} from '../../store/index.js'

import {
appState,
getStoredWallet,
userInfo,
} from '../../state/index.js'
Expand Down Expand Up @@ -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)
}
6 changes: 4 additions & 2 deletions src/utils/dash/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import {
walletFunds,
userInfo,
appComponents,
} from '../../state/index.js'

import {
Expand Down Expand Up @@ -39,6 +40,7 @@ import {
parseAddressField,
getUniqueAlias,
sortAddrs,
getContactAliases,
} from './local.js'

let defaultSocketEvents = {
Expand Down Expand Up @@ -763,7 +765,7 @@ export async function processURI(state, target, value) {
}

let preferredAlias = await getUniqueAlias(
aliases,
getContactAliases(),
preferred_username
)

Expand Down Expand Up @@ -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,
})
Expand Down

0 comments on commit 4f7e2b9

Please sign in to comment.