Skip to content

Commit db40325

Browse files
committed
fix: 🐛 minor bug fixes for contacts
1 parent ab34ae3 commit db40325

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

src/components/contacts-list.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ const initialState = {
110110
let name = c.info?.name
111111

112112
if (
113-
!name &&
113+
!name?.trim() &&
114114
!user &&
115115
!out?.xkeyId &&
116116
out?.address

src/helpers/utils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,8 @@ export async function restate(
489489
}
490490

491491
export function filterPairedContacts(contact) {
492-
return !!contact.alias || !!contact.info?.name?.trim()
492+
let outLen = Object.keys(contact.outgoing || {}).length
493+
return outLen > 0 // && !!contact.alias
493494
}
494495

495496
export function filterUnpairedContacts(contact) {

src/rigs/edit-contact.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,21 @@ export let editContactRig = (async function (globals) {
147147
</button>
148148
</footer>
149149
`,
150+
getAlias: state => {
151+
let alias = state.contact?.alias || state.contact?.info?.preferred_username
152+
if (!alias) {
153+
return ''
154+
}
155+
156+
return html`@${alias}`
157+
},
150158
content: async state => html`
151159
<fieldset class="contact">
152160
<section>
153161
${state.header(state)}
154162
<article>
155163
${await getAvatar(state.contact)}
156-
<h3>@${state.contact?.alias || state.contact?.info?.preferred_username}</h3>
164+
<h3>${state.getAlias(state)}</h3>
157165
</article>
158166
<article>
159167
<label for="contactName">
@@ -185,7 +193,7 @@ export let editContactRig = (async function (globals) {
185193
pattern="${ALIAS_REGEX.source}"
186194
spellcheck="false"
187195
autocomplete="off"
188-
value="${state.contact?.alias}"
196+
value="${state.contact?.alias || ''}"
189197
/>
190198
</div>
191199
<p>Alias for the contact (similar to a @username)</p>

0 commit comments

Comments
 (0)