Skip to content

fix(profile_image): show the contact icon when no display name is set #17866

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

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

Conversation

jrainville
Copy link
Member

What does the PR do

Fixes #17487

When no displayName, nickname, ens name or user image are set, we show the contact icon instead, in accordance to the design.

Also fixes an issue with the SuggestionBox where the colorHash was not set correctly. Then fixes an issue where right-click on contact items didn't work

Finally, this refactors some parts of the code to use UserImage instead of SmartIdenticon, as it simplifies the code and its maintenance

Affected areas

Any place where the User image/icon is shown

Architecture compliance

Screenshot of functionality (including design for comparison)

contacts-icon.webm

Impact on end user

Small impact. Only changes the icon used when the user doesn't have a displayName yet.

Also fixes small issues.

How to test

  • Have an account with a couple of contacts with varying levels of names (nothing, displayName, nickname, ens name, image)
  • Open the app and go through it to all the places that use the image

Risk

More of a medium risk since in my opinion, the worst case scenario is that the icon will just use the old Letters wrongly.
But I did refactor some small parts, so it's safer to do some good testing.

Tick one:

  • Low risk: 2 devs MUST perform testing as specified above and attach their results as comments to this PR before merging.
  • High risk: QA team MUST perform additional testing in the specified affected areas before merging.

@jrainville jrainville marked this pull request as ready for review May 6, 2025 19:19
@jrainville jrainville requested review from micieslak, caybro, alexjba and a team as code owners May 6, 2025 19:19
@jrainville jrainville requested a review from a team May 6, 2025 19:19
} else if (mouse.button === Qt.LeftButton) {
Global.openProfilePopup(model.pubKey)
onRightClicked: function () {
// FIXME: onClicked is called at the same time as onRightClicked (could be a QT5 only issue)
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a fix because the clicks didn't work anymore, but now the right-click is also broken.

It probably got introduced during the QT6 migration cc @micieslak @caybro

Copy link
Member

Choose a reason for hiding this comment

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

Were you testing on Qt5 or Qt6? Anyway, feel free to report a separate issue for this component, I'll have a look

Copy link
Member Author

Choose a reason for hiding this comment

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

Qt5

@@ -46,6 +46,8 @@ SQUtils.QObject {
preferredDisplayName: "everyone"
icon: ""
colorId: 0
colorHash: []
Copy link
Member Author

Choose a reason for hiding this comment

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

This fixes the issue with the color ring not showing in the suggestion box

@status-im-auto
Copy link
Member

status-im-auto commented May 6, 2025

Jenkins Builds

Click to see older builds (27)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ b3a9d52 #1 2025-05-06 19:28:18 ~8 min macos/aarch64 🍎dmg
✖️ b3a9d52 #1 2025-05-06 19:29:19 ~9 min tests/nim 📄log
b3a9d52 #1 2025-05-06 19:30:07 ~10 min tests/ui 📄log
b3a9d52 #1 2025-05-06 19:34:04 ~14 min windows/x86_64 📄log
✔️ b3a9d52 #1 2025-05-06 19:40:05 ~20 min macos/x86_64 🍎dmg
✔️ b3a9d52 #1 2025-05-06 19:45:15 ~25 min linux-nix/x86_64 📦tgz
✔️ b3a9d52 #1 2025-05-06 19:47:02 ~27 min linux/x86_64 📦tgz
✔️ f24c834 #2 2025-05-07 15:16:41 ~7 min macos/aarch64 🍎dmg
✔️ f24c834 #2 2025-05-07 15:19:37 ~10 min tests/nim 📄log
f24c834 #2 2025-05-07 15:23:00 ~13 min windows/x86_64 📄log
✔️ f24c834 #2 2025-05-07 15:23:33 ~13 min tests/ui 📄log
✔️ f24c834 #2 2025-05-07 15:25:09 ~15 min macos/x86_64 🍎dmg
✔️ f24c834 #2 2025-05-07 15:33:53 ~24 min linux/x86_64 📦tgz
✔️ f24c834 #2 2025-05-07 15:34:09 ~24 min linux-nix/x86_64 📦tgz
✔️ 779d843 #3 2025-05-08 14:27:29 ~7 min macos/aarch64 🍎dmg
✔️ 779d843 #3 2025-05-08 14:29:36 ~9 min tests/nim 📄log
✔️ 779d843 #3 2025-05-08 14:35:05 ~14 min tests/ui 📄log
✔️ 779d843 #3 2025-05-08 14:37:21 ~17 min macos/x86_64 🍎dmg
✔️ 779d843 #3 2025-05-08 14:43:31 ~23 min linux-nix/x86_64 📦tgz
✔️ 779d843 #3 2025-05-08 14:46:02 ~26 min linux/x86_64 📦tgz
✔️ 78f74bf #4 2025-05-09 20:56:21 ~7 min macos/aarch64 🍎dmg
✖️ 78f74bf #4 2025-05-09 20:58:39 ~9 min tests/nim 📄log
78f74bf #4 2025-05-09 21:02:50 ~13 min windows/x86_64 📄log
✔️ 78f74bf #4 2025-05-09 21:03:14 ~13 min tests/ui 📄log
✔️ 78f74bf #4 2025-05-09 21:04:47 ~15 min macos/x86_64 🍎dmg
✔️ 78f74bf #4 2025-05-09 21:12:18 ~23 min linux-nix/x86_64 📦tgz
✔️ 78f74bf #4 2025-05-09 21:15:22 ~26 min linux/x86_64 📦tgz
Commit #️⃣ Finished (UTC) Duration Platform Result
✖️ 40c8c13 #5 2025-05-12 16:02:42 ~8 min tests/nim 📄log
✔️ 40c8c13 #5 2025-05-12 16:03:54 ~9 min macos/aarch64 🍎dmg
40c8c13 #5 2025-05-12 16:06:58 ~12 min windows/x86_64 📄log
✔️ 40c8c13 #5 2025-05-12 16:08:14 ~13 min tests/ui 📄log
✔️ 40c8c13 #5 2025-05-12 16:09:30 ~15 min macos/x86_64 🍎dmg
✔️ 40c8c13 #5 2025-05-12 16:15:14 ~20 min linux-nix/x86_64 📦tgz
✔️ 40c8c13 #5 2025-05-12 16:17:39 ~23 min linux/x86_64 📦tgz
✔️ 40c8c13 #6 2025-05-12 16:34:34 ~15 min windows/x86_64 💿exe
✔️ 0c18ab2 #6 2025-05-14 19:25:11 ~7 min macos/aarch64 🍎dmg
✖️ 0c18ab2 #6 2025-05-14 19:27:24 ~9 min tests/nim 📄log
✔️ 0c18ab2 #6 2025-05-14 19:31:57 ~13 min tests/ui 📄log
✔️ 0c18ab2 #6 2025-05-14 19:33:29 ~15 min macos/x86_64 🍎dmg
✔️ 0c18ab2 #7 2025-05-14 19:36:56 ~18 min windows/x86_64 💿exe
✔️ 0c18ab2 #6 2025-05-14 19:40:03 ~22 min linux-nix/x86_64 📦tgz
✔️ 0c18ab2 #6 2025-05-14 19:44:13 ~26 min linux/x86_64 📦tgz

@jrainville jrainville force-pushed the fix/profile-icon-with-no-displayname branch 2 times, most recently from f24c834 to 779d843 Compare May 8, 2025 14:19
Copy link
Member

@micieslak micieslak left a comment

Choose a reason for hiding this comment

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

The rules of display name resolution are complicated and have been changed multiple times. I think it would be beneficial to summarize the rules in a single place as a documentation somewhere in the code (or external doc if needed). Maybe it will unveil need to do some another round of cleanup here.

Copy link
Contributor

@alexjba alexjba left a comment

Choose a reason for hiding this comment

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

Nice work!

LGTM in general! Some minor concerns

@@ -175,6 +177,8 @@ QtObject:
result = newQVariant(item.airdropAddress)
of ModelRole.MembershipRequestState:
result = newQVariant(item.membershipRequestState.int)
of ModelRole.UsesDefaultName:
result = newQVariant(resolveUsesDefaultName(item.localNickname, item.ensName, item.displayName))
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO it's preffered for the data call to return a member value as is and not to do any computation. The reasoning would be that data needs to support heavy traffic.
We've seen before some apparently harmless nim computations in data calls that proved to be very expensive.

This seems harmless indeed, but I don't see any benefit when compared to the approach you've used in src/app/modules/shared_models/message_model.nim.

Copy link
Contributor

Choose a reason for hiding this comment

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

also, would be nice to have more granular dataChanged. We're emitting UsesDefaultName changed event even when it's not actually changing.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea. I updated so that the model just passes the Item's value and I also refactored a bit so that we have an Item creator function in the model to reduce duplication

property string image
property bool showRing: !ensVerified && !root.isBridgedAccount
property bool interactive: true
property bool disabled: false
property bool ensVerified: false
property bool loading: false
property bool isBridgedAccount: false
property int onlineStatus: Constants.onlineStatus.unknown
// TODO replace this with booleans since we do not have access to Constants
Copy link
Contributor

Choose a reason for hiding this comment

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

A local enum would also work

@jrainville jrainville force-pushed the fix/profile-icon-with-no-displayname branch from 779d843 to 78f74bf Compare May 9, 2025 20:48
Copy link
Member

@caybro caybro left a comment

Choose a reason for hiding this comment

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

Looks good in general, just some smaller details/suggestions

}
return ""
}
asset.width: isContactIcon ? iconWidth * 0.9 : iconWidth
Copy link
Member

Choose a reason for hiding this comment

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

Why is this scaling the icon down? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

The icon was too big when I was working on it and I thought this is what fixed it, but turns out it's not, I just tried removing it and it doesn't change anything.

I think I need to find a way to fix it though, because it's still too big compared to the design.

Design:
image

Implementation:
image

@@ -418,7 +418,7 @@ Item {
icon.name: model.icon
icon.color: Theme.palette.userCustomizationColors[root.colorIdForPubkeyGetter(model.pubKey)]
status: model.onlineStatus
ringSettings.ringSpecModel: root.ringSpecModelGetter(model.pubKey)
Copy link
Member

Choose a reason for hiding this comment

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

You might now remove the toplevel property var ringSpecModelGetter and adjust the usages then

isImage: true
readonly property bool isContactIcon: !root.image && root.usesDefaultName

width: isContactIcon ? Math.floor(root.imageWidth * 0.9) : root.imageWidth
Copy link
Member

Choose a reason for hiding this comment

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

Again, why scaling down?

} else if (mouse.button === Qt.LeftButton) {
Global.openProfilePopup(model.pubKey)
onRightClicked: function () {
// FIXME: onClicked is called at the same time as onRightClicked (could be a QT5 only issue)
Copy link
Member

Choose a reason for hiding this comment

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

Were you testing on Qt5 or Qt6? Anyway, feel free to report a separate issue for this component, I'll have a look

Fixes #17487

When no displayName, nickname, ens name or user image are set, we show the contact icon instead, in accordance to the design.

Also fixes an issue with the SuggestionBox where the colorHash was not set correctly.
Then fixes an issue where right-click on contact items didn't work

Finally, this refactors some parts of the code to use UserImage instead of SmartIdenticon, as it simplifies the code and its maintenance
@jrainville jrainville force-pushed the fix/profile-icon-with-no-displayname branch from 40c8c13 to 0c18ab2 Compare May 14, 2025 19:17
@jrainville jrainville requested a review from noeliaSD as a code owner May 14, 2025 19:17
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.

Replace default profile image (letters) with proper icon
5 participants