Skip to content

Conversation

ajayesivan
Copy link
Collaborator

@ajayesivan ajayesivan commented May 1, 2025

fixes: #21393

Summary

This PR introduces the ability to mark or unmark a contact as untrustworthy. It enhances various parts of the app UI to reflect this new contact status.

Changes Included

UI Updates for Untrustworthy Contacts

  • Contact item, chat item, and contact screen now visually indicate when a contact is marked as untrustworthy.
  • Action drawers (in both contact list items and contact screen) include options to mark or unmark a contact as untrustworthy.

Contextual Confirmation Sheet Behavior

  • When marking a contact as untrustworthy, a confirmation sheet appears with an additional option to remove the contact.
  • If the user has received a contact request from the profile(not accepted), the confirmation sheet also shows an option to decline the request.
  • For non-contacts, no extra options are shown in the confirmation drawer.

🛠️ Other Related Changes

  • Updated the "Remove from contact" option text color to red in the action drawer (confirmed with @ilmotta & @mariia-skrypnyk here).
  • Fix: Corrected the text-combinations/username component to display the untrust icon in red instead of blue.
  • Fix: Replaced custom implementation in action-confirmation-drawer with the standardized context-tag component to fix padding issues

Screenshots

Chat Home Screen

From.home.mp4

Profile Screen

From.Profile.Screen.mp4

Contact Request Received

Contact.Request.Recieved.mp4

Not Contact & No Contact Request

Not.a.Contact.mp4
Before After
Simulator Screenshot - iPhone 13 - 2025-05-15 at 17 06 04 Simulator Screenshot - iPhone 13 - 2025-05-15 at 17 05 14
Simulator Screenshot - iPhone 13 - 2025-05-15 at 17 06 15 Simulator Screenshot - iPhone 13 - 2025-05-15 at 17 05 25

Platforms

  • Android
  • iOS

Areas that may be impacted

Functional

  • chat list
  • contact list
  • contact/profile screen
  • contact list action drawer
  • contact action drawer

Steps to test

  • Open Status
  • Navigate to Chat -> Contacts (or open a contact from contact list or 1-1 chat)
  • Long press/use the more icon to open action drawer
  • Mark as untrusted / Remove untrusted mark

status: ready

Risk

Described potential risks and worst case scenarios.

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.

@status-im-auto
Copy link
Member

status-im-auto commented May 1, 2025

Jenkins Builds

Click to see older builds (73)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ d10dcb4 #2 2025-05-01 09:13:11 ~4 min tests 📄log
✔️ d10dcb4 #2 2025-05-01 09:16:55 ~8 min android-e2e 🤖apk 📲
✔️ d10dcb4 #2 2025-05-01 09:17:27 ~9 min android 🤖apk 📲
✔️ d10dcb4 #2 2025-05-01 09:19:53 ~11 min ios 📱ipa 📲
✔️ c8eb740 #3 2025-05-05 06:19:11 ~4 min tests 📄log
✔️ c8eb740 #3 2025-05-05 06:23:51 ~9 min android-e2e 🤖apk 📲
✔️ c8eb740 #3 2025-05-05 06:24:23 ~10 min android 🤖apk 📲
✔️ c8eb740 #3 2025-05-05 06:28:14 ~13 min ios 📱ipa 📲
✔️ d358328 #4 2025-05-05 08:36:43 ~4 min tests 📄log
✔️ d358328 #4 2025-05-05 08:40:29 ~8 min android-e2e 🤖apk 📲
✔️ d358328 #4 2025-05-05 08:41:23 ~9 min android 🤖apk 📲
✔️ d358328 #4 2025-05-05 08:42:06 ~9 min ios 📱ipa 📲
✔️ e82c7d3 #5 2025-05-07 10:09:58 ~6 min tests 📄log
✔️ e82c7d3 #5 2025-05-07 10:11:06 ~8 min android-e2e 🤖apk 📲
✔️ e82c7d3 #5 2025-05-07 10:12:14 ~9 min android 🤖apk 📲
✔️ e82c7d3 #5 2025-05-07 10:16:07 ~12 min ios 📱ipa 📲
✔️ d1efbd4 #6 2025-05-14 07:13:50 ~4 min tests 📄log
✔️ d1efbd4 #6 2025-05-14 07:18:33 ~9 min android-e2e 🤖apk 📲
✔️ d1efbd4 #6 2025-05-14 07:19:06 ~10 min android 🤖apk 📲
✔️ d1efbd4 #6 2025-05-14 07:19:54 ~10 min ios 📱ipa 📲
086a302 #7 2025-05-15 07:14:22 ~52 sec ios 📄log
086a302 #7 2025-05-15 07:14:29 ~1 min android-e2e 📄log
086a302 #7 2025-05-15 07:14:42 ~1 min android 📄log
086a302 #7 2025-05-15 07:17:10 ~3 min tests 📄log
✔️ 83665bf #8 2025-05-15 07:49:04 ~4 min tests 📄log
✔️ 83665bf #8 2025-05-15 07:53:32 ~9 min android-e2e 🤖apk 📲
✔️ 83665bf #8 2025-05-15 07:54:04 ~10 min android 🤖apk 📲
✔️ 83665bf #8 2025-05-15 07:55:02 ~10 min ios 📱ipa 📲
✔️ b8ae3f2 #9 2025-05-15 08:16:21 ~4 min tests 📄log
✔️ b8ae3f2 #9 2025-05-15 08:21:01 ~9 min android-e2e 🤖apk 📲
✔️ b8ae3f2 #9 2025-05-15 08:21:32 ~10 min ios 📱ipa 📲
✔️ b8ae3f2 #9 2025-05-15 08:21:38 ~10 min android 🤖apk 📲
✔️ 8a33041 #10 2025-05-15 08:40:59 ~4 min tests 📄log
✔️ 8a33041 #10 2025-05-15 08:45:48 ~9 min android-e2e 🤖apk 📲
✔️ 8a33041 #10 2025-05-15 08:46:11 ~10 min ios 📱ipa 📲
✔️ 8a33041 #10 2025-05-15 08:46:17 ~10 min android 🤖apk 📲
✔️ 6f71f95 #11 2025-05-15 09:03:57 ~5 min tests 📄log
✔️ 6f71f95 #11 2025-05-15 09:08:06 ~9 min android-e2e 🤖apk 📲
✔️ 6f71f95 #11 2025-05-15 09:08:46 ~10 min ios 📱ipa 📲
✔️ 6f71f95 #11 2025-05-15 09:08:51 ~10 min android 🤖apk 📲
58d9c59 #12 2025-05-15 09:24:46 ~3 min tests 📄log
✔️ 58d9c59 #12 2025-05-15 09:30:39 ~9 min android-e2e 🤖apk 📲
✔️ 58d9c59 #12 2025-05-15 09:31:23 ~9 min android 🤖apk 📲
✔️ 58d9c59 #12 2025-05-15 09:31:36 ~10 min ios 📱ipa 📲
19b30ec #13 2025-05-15 10:03:01 ~2 min tests 📄log
✔️ 19b30ec #13 2025-05-15 10:08:49 ~8 min android-e2e 🤖apk 📲
✔️ 19b30ec #13 2025-05-15 10:09:10 ~8 min android 🤖apk 📲
✔️ 19b30ec #13 2025-05-15 10:10:33 ~10 min ios 📱ipa 📲
61fd103 #14 2025-05-15 10:51:26 ~2 min tests 📄log
✔️ 61fd103 #14 2025-05-15 10:57:18 ~8 min android-e2e 🤖apk 📲
✔️ 61fd103 #14 2025-05-15 10:57:46 ~8 min android 🤖apk 📲
✔️ 61fd103 #14 2025-05-15 10:58:55 ~10 min ios 📱ipa 📲
✔️ 2da47fa #15 2025-05-15 11:09:34 ~4 min tests 📄log
df2f720 #16 2025-05-15 11:14:53 ~2 min tests 📄log
✔️ df2f720 #16 2025-05-15 11:19:20 ~7 min android-e2e 🤖apk 📲
✔️ df2f720 #16 2025-05-15 11:20:52 ~8 min android 🤖apk 📲
✔️ df2f720 #16 2025-05-15 11:23:58 ~11 min ios 📱ipa 📲
✔️ d57fa7a #17 2025-05-15 11:45:52 ~4 min tests 📄log
✔️ d57fa7a #17 2025-05-15 11:48:38 ~7 min android-e2e 🤖apk 📲
✔️ d57fa7a #17 2025-05-15 11:49:16 ~7 min android 🤖apk 📲
✔️ d57fa7a #17 2025-05-15 11:51:24 ~10 min ios 📱ipa 📲
✔️ 592211c #18 2025-05-16 06:11:55 ~4 min tests 📄log
✔️ 592211c #18 2025-05-16 06:16:30 ~9 min android-e2e 🤖apk 📲
✔️ 592211c #18 2025-05-16 06:17:12 ~10 min android 🤖apk 📲
✔️ 592211c #18 2025-05-16 06:20:29 ~13 min ios 📱ipa 📲
✔️ 7a74840 #19 2025-05-19 12:34:04 ~4 min tests 📄log
✔️ 7a74840 #19 2025-05-19 12:37:46 ~8 min android-e2e 🤖apk 📲
✔️ 7a74840 #19 2025-05-19 12:38:16 ~8 min android 🤖apk 📲
✔️ 7a74840 #19 2025-05-19 12:41:39 ~12 min ios 📱ipa 📲
✔️ 0ba84aa #20 2025-05-19 14:09:23 ~4 min tests 📄log
✔️ 0ba84aa #20 2025-05-19 14:13:35 ~9 min android-e2e 🤖apk 📲
✔️ 0ba84aa #20 2025-05-19 14:14:21 ~10 min android 🤖apk 📲
✔️ 0ba84aa #20 2025-05-19 14:14:28 ~10 min ios 📱ipa 📲
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ e0af643 #21 2025-05-20 02:39:35 ~4 min tests 📄log
✔️ e0af643 #21 2025-05-20 02:43:57 ~9 min android-e2e 🤖apk 📲
✔️ e0af643 #21 2025-05-20 02:44:41 ~10 min android 🤖apk 📲
✔️ e0af643 #21 2025-05-20 02:44:46 ~10 min ios 📱ipa 📲
✔️ 6fe97f0 #22 2025-05-20 03:37:38 ~4 min tests 📄log
✔️ 6fe97f0 #22 2025-05-20 03:42:15 ~9 min android-e2e 🤖apk 📲
✔️ 6fe97f0 #22 2025-05-20 03:42:47 ~10 min ios 📱ipa 📲
✔️ 6fe97f0 #22 2025-05-20 03:42:52 ~10 min android 🤖apk 📲

@ajayesivan ajayesivan force-pushed the 21393-mark-as-untrusted branch 2 times, most recently from d358328 to e82c7d3 Compare May 7, 2025 10:02
@ajayesivan ajayesivan force-pushed the 21393-mark-as-untrusted branch from e82c7d3 to d1efbd4 Compare May 14, 2025 07:08
@ajayesivan ajayesivan marked this pull request as ready for review May 15, 2025 11:41
@ajayesivan ajayesivan force-pushed the 21393-mark-as-untrusted branch from d57fa7a to 592211c Compare May 16, 2025 06:06
@ilmotta ilmotta requested a review from a team May 16, 2025 06:42
@churik churik moved this from CONTRIBUTOR to REVIEW in Pipeline for QA May 19, 2025
Comment on lines +12 to +13
(defn hide-sheet-and-dispatch
[event]
Copy link
Contributor

Choose a reason for hiding this comment

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

I see this pattern alot in our code base, maybe we should just create an event for this. (Not blocker)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I noticed the same thing. If you agree, I can create a follow-up PR for this.

@ajayesivan ajayesivan force-pushed the 21393-mark-as-untrusted branch from 592211c to 7a74840 Compare May 19, 2025 12:29
Copy link
Contributor

@ilmotta ilmotta left a comment

Choose a reason for hiding this comment

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

The feature appears to be working well at first glance. Well done @ajayesivan

theme]
(let [photo-path (rf/sub [:chats/photo-path public-key])
online? (rf/sub [:visibility-status-updates/online? public-key])
untrustworthy? (rn/use-memo
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't cache such a cheap equality check because it will actually make things slower. Same feedback for the file src/status_im/contexts/chat/home/chat_list_item/view.cljs chat-item function in another part of the PR.

(fn [{:keys [db]} [contact-id]]
{:db (update-in db
[:contacts/contacts contact-id]
#(assoc % :trust-status constants/contact-trust-status-untrustworthy))
Copy link
Contributor

Choose a reason for hiding this comment

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

The anonymous function is unnecessary.

{:json-rpc/call
[{:method "wakuext_markAsUntrustworthy"
:params [contact-id]
:on-success #(re-frame/dispatch [:contact/mark-as-untrusted-success contact-id name])
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be changed to point to the event vector directly:

:on-success [:contact/mark-as-untrusted-success contact-id name]

(fn [{:keys [db]} [contact-id]]
{:db (update-in db
[:contacts/contacts contact-id]
#(assoc % :trust-status constants/contact-trust-status-unknown))
Copy link
Contributor

Choose a reason for hiding this comment

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

The anonymous function is unnecessary.

[:show-bottom-sheet
{:content (fn []
[confirmation-drawer/confirmation-drawer
(merge {:title (i18n/label :t/mark-as-untrusted)
Copy link
Contributor

Choose a reason for hiding this comment

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

We have been migrating many uses of merge to cond-> + assoc because merge is slow and should be used only when the keys to merge are unknown (known only at runtime).

contact-request (when request?
(rf/sub [:activity-center/pending-contact-request-from-contact-id
public-key]))]
{:dispatch
Copy link
Contributor

Choose a reason for hiding this comment

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

@ajayesivan In all event handlers, please change to use the :fx effect instead of the map syntax. See guideline

request? (= contact-request-state
constants/contact-request-state-received)
contact-request (when request?
(rf/sub [:activity-center/pending-contact-request-from-contact-id
Copy link
Contributor

Choose a reason for hiding this comment

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

Subscriptions shouldn't be used within handlers. You can reuse the computation by extracting the sub handler as a named function.

[{:method "wakuext_removeTrustStatus"
:params [contact-id]
:on-success #(re-frame/dispatch [:contact/remove-trust-status-success contact-id name])
:on-error #(log/error "failed remove contact trust status" % contact-id)}]}))
Copy link
Contributor

Choose a reason for hiding this comment

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

Error messages will be easier to digest if we pass a map as context:

(log/error "failed to remove contact trust status" {:event :contact/remove-trust-status :contact-id contact-id :error %})

(if untrustworthy?
[:contact/remove-trust-status public-key full-name]
[:contact/mark-as-untrusted-sheet contact])))
[untrustworthy? contact full-name public-key])
Copy link
Contributor

Choose a reason for hiding this comment

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

In most context menus with actions, I think it's not worth caching handlers with rn/use-callback because the rendered drawer is static the majority of the time, requiring only one render pass.

In the rare cases where the drawer with actions re-renders, the non-cached computation in the view will be just fine, assuming there are no bad usages of subs (like directly subscribing to the entire profile or entire community, etc to render a simple drawer action). This alleviates our maintainability burden to keep all these hook deps up-to-date and correct.

cc @ulisesmac since you were also participating in a discussion recently regarding "When should we cache?". cc @clauxx @flexsurfer @seanstrom

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That makes sense. I've updated my changes to remove the caching. @ilmotta if you think it's also worthwhile to remove other unnecessary caching instances from this context menu, I'd be happy to include those changes in this PR as well.

@ajayesivan ajayesivan force-pushed the 21393-mark-as-untrusted branch from 0ba84aa to e0af643 Compare May 20, 2025 02:34
@ajayesivan
Copy link
Collaborator Author

@Parveshdhull @ilmotta I’ve updated the PR with the suggested changes. Please have another look whenever you get a chance. Thanks again for the review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: REVIEW
Development

Successfully merging this pull request may close these issues.

Add an option to mark any of your contact as untrusted
6 participants