Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contacts: Refactor, bugfixes, improved logic/behaviour #2667

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

myxmaster
Copy link
Contributor

Description

First I just wanted to fix #2423. But while looking into the implementation, there was a lot more to do...

Refactor:

  • Added ContactInputField component for reusable field inputs (easier to maintain and now 1297 lines vs. before 1525)

Bugfixes:

  • Horizontal scrolling fixed for inputs (by marginHorizontal: 24 for inputContainer)
  • Using same marginTop for dividers now (normal vs. additional fields)
  • After deleting a contact clearPrefillContact() is now called -> before, old data was visible, when you deleted a contact and then created a new one
  • When editing an existing contact, proper array access checks are now done to avoid warning [mobx.array] Attempt to read an array index (0) that is out of bounds (0). Please check length first. Out of bound indices will not be tracked by MobX
  • Button label typo "add extra field" -> "Add extra field"

Improved logic/behvaiour:

  • Opacity logic removed for "Save Contact" button
  • Invalid input now visible by font color instead of divider color (better visibility and way easier logic, logic was also broken before when using additional fields)
  • "Add extra field" is now possible any time, before it was only acessible, when there was at least one LN or Onchain address and when all categories had at least 1 valid input (i think that logic was very strange, users should have the freedom to add extra fields whenever they want)
    -> "Delete" icon always visible for additional fields now of course
  • Adding an extra field now does not disable "Save Contact" button (if user tries to save with empty extra fields, that is no problem because:)
  • Contact arrays will be compacted during saveContact() with new helper function compactContactArrays() (removing empty fields/gaps)

grafik

This pull request is categorized as a:

  • New feature
  • Bug fix
  • Code refactor
  • Configuration change
  • Locales update
  • Quality assurance
  • Other

Checklist

  • I’ve run yarn run tsc and made sure my code compiles correctly
  • I’ve run yarn run lint and made sure my code didn’t contain any problematic patterns
  • I’ve run yarn run prettier and made sure my code is formatted correctly
  • I’ve run yarn run test and made sure all of the tests pass

Testing

If you modified or added a utility file, did you add new unit tests?

  • No, I’m a fool
  • Yes
  • N/A

I have tested this PR on the following platforms (please specify OS version and phone model/VM):

  • Android
  • iOS

I have tested this PR with the following types of nodes (please specify node version and API version where appropriate):

  • Embedded LND
  • LND (REST)
  • LND (Lightning Node Connect)
  • Core Lightning (CLNRest)
  • LndHub
  • [DEPRECATED] Core Lightning (c-lightning-REST)
  • [DEPRECATED] Core Lightning (Spark)
  • [DEPRECATED] Eclair

Locales

  • I’ve added new locale text that requires translations
  • I’m aware that new translations should be made on the ZEUS Transfix page and not directly to this repo

Third Party Dependencies and Packages

  • Contributors will need to run yarn after this PR is merged in
  • 3rd party dependencies have been modified:
    • verify that package.json and yarn.lock have been properly updated
    • verify that dependencies are installed for both iOS and Android platforms

Other:

  • Changes were made that require an update to the README
  • Changes were made that require an update to onboarding

@kaloudis
Copy link
Contributor

There seems to be a ton of changes here.

This PR would be way easier to grok if split up into more commits.

Copy link
Contributor

@shubhamkmr04 shubhamkmr04 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot_1734936814
when we try to change bolt12Address input
(This happens when we are editing nostr contacts)

@shubhamkmr04
Copy link
Contributor

shubhamkmr04 commented Dec 23, 2024

Simulator Screenshot - iPhone 16 Pro Max - 2024-12-23 at 12 25 45
we shouldn't be able to save contacts when we have empty extra inputs

@myxmaster
Copy link
Contributor Author

myxmaster commented Dec 23, 2024

we shouldn't be able to save contacts when we have empty extra inputs

No reason to worry about it anymore with the helper function compactContactArrays() in ContactStore -> User now does not have to remove unused extra fields anymore, it will be done automatically during save.

- Add ContactInputField component for reusable field inputs
- Enhance "add extra field" logic and button disable conditions
- Add compactContactArrays helper function to prevent saving empty additional fields/gaps
- Fix localeString typo
- Fix MobX array out of bounds warnings with proper array access checks
@myxmaster
Copy link
Contributor Author

when we try to change bolt12Address input
(This happens when we are editing nostr contacts)

Yes, found that bug and fixed it. Problem was that setPrefillContact() was not initializing an array at all if no data was there.
-> I also noticed bolt12Offer was missing completely, so added that too now.

@kaloudis kaloudis changed the title Contacs: Refactor, bugfixes, improved logic/behaviour Contacts: Refactor, bugfixes, improved logic/behaviour Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Text inputs in Contact detail view need some padding-right
3 participants