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

fix: No toast on removal of untrusted mark #16972

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

caybro
Copy link
Member

@caybro caybro commented Dec 13, 2024

What does the PR do

  • listen to the NIM's signal SIGNAL_REMOVED_TRUST_STATUS
  • emit a signal for QML signal accordingly
  • emit a toast/notification as a result

Fixes #16949

Affected areas

Profile

Architecture compliance

Screenshot of functionality (including design for comparison)

  • I've checked the design and this PR matches it

Marked as untrusted:
Snímek obrazovky z 2024-12-16 11-40-18

Removed the untrusted mark:
image

@caybro caybro linked an issue Dec 13, 2024 that may be closed by this pull request
@status-im-auto
Copy link
Member

status-im-auto commented Dec 13, 2024

Jenkins Builds

Click to see older builds (35)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ a650a86 #1 2024-12-13 23:38:40 ~6 min macos/aarch64 🍎dmg
✔️ a650a86 #1 2024-12-13 23:40:34 ~8 min tests/nim 📄log
✔️ a650a86 #1 2024-12-13 23:44:19 ~11 min tests/ui 📄log
✔️ a650a86 #1 2024-12-13 23:48:25 ~16 min macos/x86_64 🍎dmg
✔️ a650a86 #1 2024-12-13 23:51:51 ~19 min linux-nix/x86_64 📦tgz
✔️ a650a86 #1 2024-12-13 23:52:11 ~19 min linux/x86_64 📦tgz
✔️ a650a86 #1 2024-12-13 23:54:15 ~21 min windows/x86_64 💿exe
✔️ 3d29949 #2 2024-12-16 10:23:48 ~4 min macos/aarch64 🍎dmg
✔️ 3d29949 #2 2024-12-16 10:27:05 ~7 min tests/nim 📄log
✔️ 3d29949 #2 2024-12-16 10:30:42 ~11 min macos/x86_64 🍎dmg
✔️ 3d29949 #2 2024-12-16 10:31:12 ~11 min tests/ui 📄log
✔️ 3d29949 #2 2024-12-16 10:35:37 ~16 min linux-nix/x86_64 📦tgz
✔️ 3d29949 #2 2024-12-16 10:37:37 ~18 min linux/x86_64 📦tgz
✔️ 3d29949 #2 2024-12-16 10:39:21 ~20 min windows/x86_64 💿exe
✔️ 4501e9e #3 2024-12-16 11:02:02 ~5 min macos/aarch64 🍎dmg
✔️ 4501e9e #3 2024-12-16 11:04:31 ~7 min tests/nim 📄log
✔️ 4501e9e #3 2024-12-16 11:07:23 ~10 min macos/x86_64 🍎dmg
✔️ 4501e9e #3 2024-12-16 11:08:53 ~12 min tests/ui 📄log
✔️ 4501e9e #3 2024-12-16 11:12:31 ~15 min linux-nix/x86_64 📦tgz
✔️ 4501e9e #3 2024-12-16 11:15:03 ~18 min linux/x86_64 📦tgz
✔️ 4501e9e #3 2024-12-16 11:16:15 ~19 min windows/x86_64 💿exe
✔️ 044f802 #4 2024-12-16 17:15:32 ~4 min macos/aarch64 🍎dmg
✔️ 044f802 #4 2024-12-16 17:18:51 ~7 min tests/nim 📄log
✔️ 044f802 #4 2024-12-16 17:22:20 ~11 min macos/x86_64 🍎dmg
✔️ 044f802 #4 2024-12-16 17:23:03 ~12 min tests/ui 📄log
✔️ 044f802 #4 2024-12-16 17:27:29 ~16 min linux-nix/x86_64 📦tgz
✔️ 044f802 #4 2024-12-16 17:29:20 ~18 min linux/x86_64 📦tgz
✔️ 044f802 #4 2024-12-16 17:30:14 ~19 min windows/x86_64 💿exe
✔️ 83d5fb2 #5 2024-12-16 18:28:36 ~4 min macos/aarch64 🍎dmg
✔️ 83d5fb2 #5 2024-12-16 18:32:03 ~7 min tests/nim 📄log
✔️ 83d5fb2 #5 2024-12-16 18:35:03 ~10 min macos/x86_64 🍎dmg
83d5fb2 #5 2024-12-16 18:35:59 ~11 min tests/ui 📄log
✔️ 83d5fb2 #5 2024-12-16 18:40:07 ~15 min linux-nix/x86_64 📦tgz
✔️ 83d5fb2 #5 2024-12-16 18:43:00 ~18 min windows/x86_64 💿exe
✔️ 83d5fb2 #5 2024-12-16 18:43:54 ~19 min linux/x86_64 📦tgz
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ d9006a7 #6 2024-12-16 22:50:41 ~4 min macos/aarch64 🍎dmg
✔️ d9006a7 #6 2024-12-16 22:54:12 ~7 min tests/nim 📄log
✔️ d9006a7 #6 2024-12-16 22:56:51 ~10 min macos/x86_64 🍎dmg
✔️ d9006a7 #6 2024-12-16 22:58:17 ~11 min tests/ui 📄log
✔️ d9006a7 #6 2024-12-16 23:02:14 ~15 min linux-nix/x86_64 📦tgz
✔️ d9006a7 #6 2024-12-16 23:04:39 ~18 min linux/x86_64 📦tgz
✔️ d9006a7 #6 2024-12-16 23:05:48 ~19 min windows/x86_64 💿exe
✔️ 840fd78 #7 2024-12-17 18:38:22 ~4 min macos/aarch64 🍎dmg
✔️ 840fd78 #7 2024-12-17 18:41:33 ~7 min tests/nim 📄log
✔️ 840fd78 #7 2024-12-17 18:45:01 ~11 min macos/x86_64 🍎dmg
✔️ 840fd78 #7 2024-12-17 18:45:44 ~12 min tests/ui 📄log
✔️ 840fd78 #7 2024-12-17 18:50:18 ~16 min linux-nix/x86_64 📦tgz
✔️ 840fd78 #7 2024-12-17 18:52:12 ~18 min linux/x86_64 📦tgz
✔️ 840fd78 #7 2024-12-17 18:52:50 ~19 min windows/x86_64 💿exe

@caybro caybro force-pushed the 16949-no-toast-on-removal-of-untrusted-mark branch 2 times, most recently from 3d29949 to 4501e9e Compare December 16, 2024 10:56
@caybro caybro marked this pull request as ready for review December 16, 2024 10:56
@caybro caybro force-pushed the 16949-no-toast-on-removal-of-untrusted-mark branch from 4501e9e to 044f802 Compare December 16, 2024 17:10
@caybro caybro requested a review from a team as a code owner December 16, 2024 17:10
Copy link
Member

@jrainville jrainville left a comment

Choose a reason for hiding this comment

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

Some suggestions

@caybro caybro force-pushed the 16949-no-toast-on-removal-of-untrusted-mark branch 2 times, most recently from 83d5fb2 to d9006a7 Compare December 16, 2024 22:46
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.

Looks nice besides some architectural considerations (in comments).

const displayName = SQUtils.Emoji.parse(ProfileUtils.displayName(contactDetails.localNickname, contactDetails.name, contactDetails.displayName, contactDetails.alias))
Global.displaySuccessToastMessage(qsTr("Trust mark removed for %1").arg(displayName))
}
}
Copy link
Member

Choose a reason for hiding this comment

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

There are some problems and several potential solutions there.

  1. According to the guide, stores are just thin wrapper over context properties exposed from Nim. There should be no UI interaction from stores but displaying toast message definitely is.

So, the ContactsStore should have signal trustStatusRemoved(...), and store should just re-emit the signal from contactsModuleInst, e.g. via d.contactsModuleInst.trustStatusRemoved.connect(root.trustStatusRemoved).

The actual handling of that signal should be done outside of the store, ideally in some places dedicated to toasts generation.

  1. The target is to eliminate Utils.getContactDetailsAsJson because we have everything in the contactsModel. There is even no need to use ProfileUtils.displayName because there is PreferredDisplayName providing the same thing directly from the model. So instead of getContactDetailsAsJson just ModelUtils.getByKey(...) for preferredDisplayName role can be used there.

  2. We could consider handling such notifications exclusively on the UI side by observing the model and filtering the operations we want to notify to the user via toasts. Then no specific signal from the store is needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah good ideas; I'll just probably emit a signal here, and catch it in the ToastsManager. One potential pitfall, the ContactsStore is not a toplevel one, it's created as a substore of RootStore

Option nr. 3 is something I had on mind too but seemed too complex to do here just for one action. The other (complexity) problem is that the proposed solution is simply incomplete: if you look at Popups.qml, we don't want to display a series of notifications as a result of performing single backend calls, but rather combine and group them in case we're performing several actions (cf Popups.qml, e.g. the noitifications inside RemoveContactPopup)

Copy link
Member

Choose a reason for hiding this comment

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

One thing that just popped in my mind, is there a chance that we initialized more than one ContactsStore? If so, then we'd fire two toast messages?
That might be an argument to move the Connections to another place, though I don't have an idea where it should be 🤷

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, if I understood correctly, it's another reason to decouple toast creation from the place where the action is called in UI. By observing model we can register events and emit notifications using Qt.callLater or even some delay, where the only the last call will be actually executed, aggregating all events into single nofification.

Copy link
Member

Choose a reason for hiding this comment

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

@jrainville that's possible and it would lead to undesired behavior. But first thing is that store shouldn't do that to respect separation of concerns and the architecture we established via the guideline.

Copy link
Member Author

Choose a reason for hiding this comment

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

So far it looks like the ContactsStore is really instantiated only once as part of the toplevel RootStore :) But one can never be too sure :D

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

In action:

Snímek obrazovky z 2024-12-17 19-32-43

image

Copy link
Member Author

Choose a reason for hiding this comment

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

Got me thinking, would be a nice test for the stores if we don't instantiate them multiple times 😆 Here it works, otherwise we'd get multiple notifications

- listen to the NIM's signal `SIGNAL_REMOVED_TRUST_STATUS`
- emit a signal for QML signal accordingly
- emit a toast/notification as a result

Fixes #16949
@caybro caybro force-pushed the 16949-no-toast-on-removal-of-untrusted-mark branch from d9006a7 to 840fd78 Compare December 17, 2024 18:33
Copy link
Member

@jrainville jrainville left a comment

Choose a reason for hiding this comment

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

Nice job

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.

nice!

@caybro caybro merged commit 8aebb81 into master Dec 18, 2024
9 checks passed
@caybro caybro deleted the 16949-no-toast-on-removal-of-untrusted-mark branch December 18, 2024 10:26
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.

No toast on removal of untrusted mark
4 participants