Skip to content

Commit

Permalink
Add maps to pass params
Browse files Browse the repository at this point in the history
  • Loading branch information
ulisesmac committed Jan 21, 2025
1 parent e1be123 commit a2ac2a4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
7 changes: 5 additions & 2 deletions src/status_im/contexts/profile/edit/accent_colour/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[utils.re-frame :as rf]))

(rf/reg-event-fx :profile/edit-accent-colour-success
(fn [_ [customization-color navigate-back? show-toast?]]
(fn [_ [{:keys [customization-color navigate-back? show-toast?]}]]
{:fx [[:dispatch [:profile/save-local-accent-color customization-color]]
(when navigate-back?
[:dispatch [:navigate-back]])
Expand All @@ -29,7 +29,10 @@
[{:method "wakuext_setCustomizationColor"
:params [{:customizationColor color
:keyUid key-uid}]
:on-success [:profile/edit-accent-colour-success color navigate-back? show-toast?]
:on-success [:profile/edit-accent-colour-success
{:customization-color color
:navigate-back? navigate-back?
:show-toast? show-toast?}]
:on-error #(log/error "failed to edit accent color." {:error %})}]]]}))

(rf/reg-event-fx :profile/edit-accent-colour edit-accent-colour)
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
[{:method "wakuext_setCustomizationColor"
:params [{:customizationColor new-color
:keyUid key-uid}]
:on-success [:profile/edit-accent-colour-success new-color true true]
:on-success [:profile/edit-accent-colour-success
{:customization-color new-color
:navigate-back? true
:show-toast? true}]
:on-error fn?}]]]}]
(is (match? expected
(sut/edit-accent-colour cofx [{:color new-color}])))))
8 changes: 4 additions & 4 deletions src/status_im/contexts/profile/edit/header/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
(update db :profile/profile dissoc :images))}))

(rf/reg-event-fx :profile/edit-profile-picture-success
(fn [{db :db} [show-toast? images]]
(fn [{db :db} [{:keys [show-toast?]} images]]
(let [has-picture? (-> db :profile/profile :images count pos?)]
{:fx [[:dispatch [:profile/update-local-picture (reverse images)]]
(when show-toast?
Expand All @@ -34,12 +34,12 @@
{:fx [[:json-rpc/call
[{:method "multiaccounts_storeIdentityImage"
:params [key-uid path 0 0 crop-width crop-height]
:on-success [:profile/edit-profile-picture-success show-toast?]}]]]}))
:on-success [:profile/edit-profile-picture-success {:show-toast? show-toast?}]}]]]}))

(rf/reg-event-fx :profile/edit-picture edit-profile-picture)

(rf/reg-event-fx :profile/delete-profile-picture-success
(fn [_ [show-toast?]]
(fn [_ [{:keys [show-toast?]}]]
{:fx [[:dispatch [:profile/update-local-picture nil]]
(when show-toast?
[:dispatch
Expand All @@ -56,6 +56,6 @@
{:fx [[:json-rpc/call
[{:method "multiaccounts_deleteIdentityImage"
:params [key-uid]
:on-success [:profile/delete-profile-picture-success show-toast?]}]]]}))
:on-success [:profile/delete-profile-picture-success {:show-toast? show-toast?}]}]]]}))

(rf/reg-event-fx :profile/delete-picture delete-profile-picture)
4 changes: 2 additions & 2 deletions src/status_im/contexts/profile/edit/header/events_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[{:method "multiaccounts_storeIdentityImage"
:params [key-uid picture 0 0 profile-picture-picker/crop-size
profile-picture-picker/crop-size]
:on-success [:profile/edit-profile-picture-success true]}]]]}]
:on-success [:profile/edit-profile-picture-success {:show-toast? true}]}]]]}]
(is (match? expected
(sut/edit-profile-picture cofx [{:picture picture}])))))

Expand All @@ -22,6 +22,6 @@
expected {:fx [[:json-rpc/call
[{:method "multiaccounts_deleteIdentityImage"
:params [key-uid]
:on-success [:profile/delete-profile-picture-success true]}]]]}]
:on-success [:profile/delete-profile-picture-success {:show-toast? true}]}]]]}]
(is (match? expected
(sut/delete-profile-picture cofx [{}])))))

0 comments on commit a2ac2a4

Please sign in to comment.