Skip to content

Commit

Permalink
fix: fix issue with empty contact screen (#888)
Browse files Browse the repository at this point in the history
* fixed issue with not trimmed names for contacts

* minor fix

* minor code improvements

---------

Co-authored-by: ost-ptk <[email protected]>
Co-authored-by: Vynnyk Dmytro <[email protected]>
  • Loading branch information
3 people authored Dec 13, 2023
1 parent ce0b3dc commit aaa5122
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/apps/popup/pages/add-contact/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ export const AddContactPage = () => {
const lastModified = new Date().toISOString();

dispatchToMainStore(
newContactAdded({ name, publicKey, lastModified: lastModified })
newContactAdded({
name: name.trim(),
publicKey,
lastModified
})
).finally(() => {
setShowSuccessScreen(true);
});
Expand Down
6 changes: 3 additions & 3 deletions src/apps/popup/pages/contact-details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ export const ContactDetailsPage = () => {
dispatchToMainStore(
contactUpdated({
oldName: contact.name,
name: newName,
publicKey: publicKey,
lastModified: lastModified
name: newName.trim(),
publicKey,
lastModified
})
).finally(() => {
navigate(RouterPath.ContactList);
Expand Down
3 changes: 2 additions & 1 deletion src/libs/ui/forms/contact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export const useContactForm = (
) => {
const newContactFormSchema = Yup.object().shape({
name: useContactNameRule(
value => value != null && !existingContactNames.includes(value)
value =>
value?.trim() != null && !existingContactNames.includes(value?.trim())
),
publicKey: useContactPublicKeyRule()
});
Expand Down

0 comments on commit aaa5122

Please sign in to comment.