-
Notifications
You must be signed in to change notification settings - Fork 1k
feat: add/remove untrusted mark from contacts #22562
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
ajayesivan
wants to merge
20
commits into
status-im:develop
Choose a base branch
from
ajayesivan:21393-mark-as-untrusted
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+238
−109
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
61e0780
fix: confirmation drawer context tag
ajayesivan 56b34a1
wip: mark as untrusted option & drawer
ajayesivan bb31ef4
Implement trust status actions
ajayesivan cc72533
Show trust mark in contacts
ajayesivan 491e25e
Add divider
ajayesivan ef38681
remove from contacts option
ajayesivan b135670
move mark as untrusted confirmation drawer to event
ajayesivan bca695a
show trust status in chat list
ajayesivan 8757c5f
trust mark in profile page
ajayesivan bbfdd7f
mark untrusted option in contact screen
ajayesivan 048b7ac
self reivew changes
ajayesivan 0c2beac
handle names properly
ajayesivan 93a61d5
Decline contact request option
ajayesivan 9806900
fix: decline contact request logic
ajayesivan cca3c6b
lint-fix
ajayesivan 9f968b5
self review improvements
ajayesivan 464d3f7
lint-fix
ajayesivan e0af643
untrusted toast copy update
ajayesivan 9e996c1
pr review changes
ajayesivan 6fe97f0
remove use of subs in events
ajayesivan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,10 @@ | ||
(ns status-im.common.confirmation-drawer.style | ||
(:require | ||
[quo.foundations.colors :as colors])) | ||
|
||
(defn context-container | ||
[theme] | ||
{:flex-direction :row | ||
:background-color (colors/theme-colors colors/neutral-10 colors/neutral-80 theme) | ||
:border-radius 20 | ||
:align-items :center | ||
:align-self :flex-start | ||
:padding 2 | ||
:margin-top 4 | ||
:margin-bottom 16}) | ||
(ns status-im.common.confirmation-drawer.style) | ||
|
||
(def buttons-container | ||
{:flex-direction :row | ||
:justify-content :space-between | ||
:margin-top 25}) | ||
|
||
(def context-tag | ||
{:margin-bottom 12 | ||
:margin-top 4}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
(ns status-im.contexts.contact.trust.events | ||
(:require | ||
[status-im.common.confirmation-drawer.view :as confirmation-drawer] | ||
[status-im.constants :as constants] | ||
[status-im.contexts.profile.utils :as profile.utils] | ||
[taoensso.timbre :as log] | ||
[utils.i18n :as i18n] | ||
[utils.re-frame :as rf])) | ||
|
||
(rf/reg-event-fx :contact/mark-as-untrusted-success | ||
(fn [{:keys [db]} [contact-id]] | ||
{:db (update-in db | ||
[:contacts/contacts contact-id] | ||
assoc | ||
:trust-status | ||
constants/contact-trust-status-untrustworthy) | ||
:fx [[:dispatch | ||
[:toasts/upsert | ||
{:type :positive | ||
:text (i18n/label :t/marked-as-untrusted)}]]]})) | ||
|
||
(rf/reg-event-fx :contact/mark-as-untrusted | ||
(fn [_ [contact-id name]] | ||
{:json-rpc/call | ||
[{:method "wakuext_markAsUntrustworthy" | ||
:params [contact-id] | ||
:on-success [:contact/mark-as-untrusted-success contact-id name] | ||
:on-error #(log/error "failed mark contact as untrusted" | ||
{:event :contact/mark-as-untrusted | ||
:contact-id contact-id | ||
:error %})}]})) | ||
|
||
(rf/reg-event-fx :contact/remove-trust-status-success | ||
(fn [{:keys [db]} [contact-id]] | ||
{:db (update-in db | ||
[:contacts/contacts contact-id] | ||
assoc | ||
:trust-status | ||
constants/contact-trust-status-unknown) | ||
:fx [[:dispatch | ||
[:toasts/upsert | ||
{:type :positive | ||
:text (i18n/label :t/untrusted-mark-removed)}]]]})) | ||
|
||
(rf/reg-event-fx :contact/remove-trust-status | ||
(fn [_ [contact-id name]] | ||
{:json-rpc/call | ||
[{:method "wakuext_removeTrustStatus" | ||
:params [contact-id] | ||
:on-success [:contact/remove-trust-status-success contact-id name] | ||
:on-error #(log/error "failed remove contact trust status" | ||
{:event :contact/remove-trust-status | ||
:contact-id contact-id | ||
:error %})}]})) | ||
|
||
(defn pending-contact-request-from-contact-id | ||
[db contact-id] | ||
(->> (get-in db [:activity-center :contact-requests]) | ||
(filter #(= contact-id (:author %))) | ||
first)) | ||
|
||
(rf/reg-event-fx :contact/mark-as-untrusted-sheet | ||
(fn [{:keys [db]} [{:keys [public-key contact-request-state] :as contact}]] | ||
(let [name (profile.utils/displayed-name contact) | ||
contact? (= contact-request-state | ||
constants/contact-request-state-mutual) | ||
request? (= contact-request-state | ||
constants/contact-request-state-received) | ||
contact-request (when request? | ||
(pending-contact-request-from-contact-id db public-key))] | ||
{:fx [[:dispatch | ||
[:show-bottom-sheet | ||
{:content (fn [] | ||
[confirmation-drawer/confirmation-drawer | ||
(cond-> {:title (i18n/label :t/mark-as-untrusted) | ||
:description (i18n/label :t/mark-as-untrusted-description | ||
{:username (:primary-name contact)}) | ||
:context contact | ||
:accessibility-label :mark-as-untrustworthy | ||
:button-text (i18n/label :t/mark-as-untrusted-button) | ||
:on-press (fn [] | ||
(rf/dispatch [:hide-bottom-sheet]) | ||
(rf/dispatch | ||
[:contact/mark-as-untrusted | ||
public-key name]))} | ||
contact? | ||
(assoc :extra-action (fn [] | ||
(rf/dispatch [:contact.ui/remove-contact-pressed | ||
contact])) | ||
:extra-text (i18n/label :t/remove-contact)) | ||
request? | ||
(assoc :extra-action (fn [] | ||
(rf/dispatch | ||
[:activity-center.contact-requests/decline | ||
(:id contact-request)])) | ||
:extra-text (i18n/label :t/decline-contact-request)))])}]]]}))) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.