Skip to content

Commit

Permalink
fix contact createion in new chat dialog not working with leading or …
Browse files Browse the repository at this point in the history
…trailing spaces.

closes #3357
  • Loading branch information
Simon-Laux committed Aug 28, 2023
1 parent c24b8a7 commit ef4e4a0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### Changed

### Fixed
- fix contact createion in new chat dialog not working with leading or trailing spaces. #3357

<a id="1_40_0"></a>

Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/chat/ChatList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export default function ChatList(props: {

const contactId = await BackendRemote.rpc.createContact(
selectedAccountId(),
queryStr,
queryStr.trim(),
null
)
await createChatByContactIdAndSelectIt(contactId)
Expand Down Expand Up @@ -398,7 +398,7 @@ export default function ChatList(props: {
queryStrIsValidEmail && (
<div style={{ width: width }}>
<PseudoListItemAddContact
queryStr={queryStr || ''}
queryStr={queryStr?.trim() || ''}
queryStrIsEmail={queryStrIsValidEmail}
onClick={addContactOnClick}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/contact/ContactList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ export function useContactIds(listFlags: number, queryStr: string | undefined) {
const contactIds = await BackendRemote.rpc.getContactIds(
accountId,
listFlags,
queryStr || null
queryStr?.trim() || null
)
const queryStrIsValidEmail = await BackendRemote.rpc.checkEmailValidity(
queryStr || ''
queryStr?.trim() || ''
)
setState({ contactIds, queryStrIsValidEmail })
}, 200),
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/components/dialogs/CreateChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export default function CreateChat(props: {

const contactId = await BackendRemote.rpc.createContact(
selectedAccountId(),
queryStr,
queryStr.trim(),
null
)
await createChatByContactIdAndSelectIt(contactId)
Expand All @@ -122,13 +122,13 @@ export default function CreateChat(props: {
if (
queryStr === '' ||
(contacts.length === 1 &&
contacts[0].address.toLowerCase() === queryStr.toLowerCase())
contacts[0].address.toLowerCase() === queryStr.trim().toLowerCase())
) {
return null
}
return (
<PseudoListItemAddContact
queryStr={queryStr}
queryStr={queryStr.trim()}
queryStrIsEmail={queryStrIsValidEmail}
onClick={addContactOnClick}
/>
Expand Down

0 comments on commit ef4e4a0

Please sign in to comment.