Skip to content

Commit

Permalink
[#18453] fix: save accent color from signal response
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsen-ghafouri committed Feb 5, 2024
1 parent c8bb9ab commit aba5dd3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
(js-delete response-js "customizationColor")
(rf/merge cofx
(process-next response-js sync-handler)
(rf/dispatch [:profile/edit-accent-colour customization-color]))))))
(rf/dispatch [:profile/save-local-accent-color (keyword customization-color)]))))))

(defn group-by-and-update-unviewed-counts
"group messages by current chat, profile updates, transactions and update unviewed counters in db for not curent chats"
Expand Down
14 changes: 9 additions & 5 deletions src/status_im/contexts/profile/edit/accent_colour/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,27 @@
[utils.re-frame :as rf]))

(rf/reg-event-fx :profile/edit-accent-colour-success
(fn [_]
{:fx [[:dispatch [:navigate-back]]
(fn [_ [customization-color]]
{:fx [[:dispatch [:profile/save-local-accent-color customization-color]]
[:dispatch [:navigate-back]]
[:dispatch
[:toasts/upsert
{:type :positive
:theme :dark
:text (i18n/label :t/accent-colour-updated)}]]]}))

(rf/reg-event-fx :profile/save-local-accent-color
(fn [{:keys [db]} [customization-color]]
{:db (assoc-in db [:profile/profile :customization-color] customization-color)}))

(defn edit-accent-colour
[{:keys [db]} [customization-color]]
(let [key-uid (get-in db [:profile/profile :key-uid])]
{:db (assoc-in db [:profile/profile :customization-color] customization-color)
:fx [[:json-rpc/call
{:fx [[:json-rpc/call
[{:method "wakuext_setCustomizationColor"
:params [{:customizationColor customization-color
:keyUid key-uid}]
:on-success [:profile/edit-accent-colour-success]
:on-success [:profile/edit-accent-colour-success customization-color]
: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,7 @@
[{:method "wakuext_setCustomizationColor"
:params [{:customizationColor new-color
:keyUid key-uid}]
:on-success [:profile/edit-accent-colour-success]
:on-success [:profile/edit-accent-colour-success new-color]
:on-error fn?}]]]}]
(is (match? expected
(sut/edit-accent-colour cofx [new-color])))))
4 changes: 2 additions & 2 deletions status-go-version.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"owner": "status-im",
"repo": "status-go",
"version": "feat/change-accent-colour",
"commit-sha1": "af7f5c4404a3edb0d2d14a91d75460b10a4cdc2c",
"src-sha256": "1bpcyjcgh0baw1pdqlm3ndm8in823pcfimn8zwdvqisxcj35sl2m"
"commit-sha1": "3b9d813f4b1d815c11f56abc93c4d6bfe16d4b5b",
"src-sha256": "0grzw3fa9b25ph6i64inwbsr9nrgs2jzgz9v3db88q8jwlwn15sz"
}

0 comments on commit aba5dd3

Please sign in to comment.