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

Add "Display" to the Name textfield header on the edit profile page. #1456

Merged
merged 9 commits into from
Sep 6, 2024

Conversation

pelumy
Copy link
Contributor

@pelumy pelumy commented Sep 4, 2024

Issues covered

#1445

Description

This PR updates "Name" to "Display Name" in the EditProfile page

  • The value of the displayName key was capitalised in the Localizable file
  • The localized displayName key is used to replace the previous localized name key

How to test

  1. Build the code
  2. Tap the Profile tab on the bottom right
  3. Tap the Edit Profile button on the page
  4. Please check that under the Basic Information category, the "Name" header has been changed to "Display Name".

Screenshots/Video

Before After
Before After

Copy link

github-actions bot commented Sep 4, 2024

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@pelumy
Copy link
Contributor Author

pelumy commented Sep 4, 2024

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Sep 4, 2024
@pelumy pelumy changed the title Edit profile/display name editProfile/display-name Sep 4, 2024
@pelumy pelumy changed the title editProfile/display-name Add "Display" to the Name textfield header on the edit profile page. Sep 4, 2024
Copy link
Member

@mplorentz mplorentz left a comment

Choose a reason for hiding this comment

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

This perfectly does what is asked for in the ticket, but I think the ticket description left something out.

The data for a Nostr profile is stored in a "metadata" event, and there are two name fields in the metadata event: name and display_name. These are mapped to the properties on our Author class called name and displayName. Since we changed the label in the UI I think we also need to change the code that saves the name to use author.displayName instead of author.name. It looks like you can do this in ProfileEditView.save().

You weren't expected to figure this out on your own, I just happened to notice it while reviewing. Can you make that change and then request another review?

@pelumy
Copy link
Contributor Author

pelumy commented Sep 4, 2024

This perfectly does what is asked for in the ticket, but I think the ticket description left something out.

The data for a Nostr profile is stored in a "metadata" event, and there are two name fields in the metadata event: name and display_name. These are mapped to the properties on our Author class called name and displayName. Since we changed the label in the UI I think we also need to change the code that saves the name to use author.displayName instead of author.name. It looks like you can do this in ProfileEditView.save().

You weren't expected to figure this out on your own, I just happened to notice it while reviewing. Can you make that change and then request another review?

Thanks for pointing this out Matt. I have a few questions:|

  • Does this also mean we would change the @state var name from name to displayName?
  • Also, why don't we have two different textfields for name and displayName, if we have both in the Author metadata?

@@ -166,15 +166,15 @@ struct ProfileEditView: View {

private func populateTextFields() {
viewContext.refresh(author, mergeChanges: true)
nameText = author.name ?? author.displayName ?? ""
displayNameText = author.displayName ?? author.name ?? ""
Copy link
Member

Choose a reason for hiding this comment

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

Hey @pelumy, this looks good and accomplishes what I asked for in my last comment. However I found one weird flow on my test account that I would like to smooth out before we merge. It looks like if the user has only set a name in Nos but never a displayName then we actually show an empty displayName field. I think this is happening because we have been saving an empty string into the displayName field, so this line of code ends up evaulating as displayNameText = "". It looks a little weird:

Screen.Recording.2024-09-05.at.3.43.52.PM.mov

Can you tweak this so that it uses the name if author.displayName is nil or empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ooh, thanks for catching this @mplorentz . I will push a fix for this.

@pelumy
Copy link
Contributor Author

pelumy commented Sep 5, 2024

@mplorentz , I have pushed the fix and the video below shows:

First screen, a new test account with only name set
After new build, the new test account with the empty display name
After new build, the new test account with the name displayed under the display name.
https://github.com/user-attachments/assets/f073f444-4266-4930-8f36-2e0e79532f95

I also made sure to test that the displayName still shows for accounts that already saved the displayName.

Copy link
Member

@mplorentz mplorentz left a comment

Choose a reason for hiding this comment

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

This is good to go now. Nice work @pelumy!

@pelumy pelumy added this pull request to the merge queue Sep 6, 2024
Merged via the queue into main with commit 855c000 Sep 6, 2024
4 checks passed
@pelumy pelumy deleted the editProfile/display-name branch September 6, 2024 13:48
@joshuatbrown
Copy link
Contributor

@pelumy awesome work on your first PR -- this is great!

@pelumy
Copy link
Contributor Author

pelumy commented Sep 6, 2024

Thank you @joshuatbrown 😊

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.

3 participants