From cb9ae21cf2ba89bd0e819a32280de56300eea9e6 Mon Sep 17 00:00:00 2001 From: frank Date: Tue, 19 Sep 2023 22:05:59 +0800 Subject: [PATCH] process backedup(profile/settings) signal (#17306) --- src/status_im/signals/core.cljs | 4 ++++ src/status_im2/contexts/profile/events.cljs | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/status_im/signals/core.cljs b/src/status_im/signals/core.cljs index c25a095865..fe62586a2a 100644 --- a/src/status_im/signals/core.cljs +++ b/src/status_im/signals/core.cljs @@ -145,5 +145,9 @@ (js->clj event-js :keywordize-keys true)) "curated.communities.update" (rf/dispatch [:fetched-contract-communities (js->clj event-js :keywordize-keys true)]) + "waku.backedup.profile" (rf/dispatch [:profile/update-profile-from-backup + (js->clj event-js :keywordize-keys true)]) + "waku.backedup.settings" (rf/dispatch [:profile/update-setting-from-backup + (js->clj event-js :keywordize-keys true)]) (log/debug "Event " type " not handled")))) diff --git a/src/status_im2/contexts/profile/events.cljs b/src/status_im2/contexts/profile/events.cljs index d996873bd7..2e5d2c725d 100644 --- a/src/status_im2/contexts/profile/events.cljs +++ b/src/status_im2/contexts/profile/events.cljs @@ -47,3 +47,13 @@ ;;if succeed "node.login" signal will be triggered (login/login-with-biometric-if-available key-uid))) (navigation/init-root cofx :intro))) + +(rf/defn update-setting-from-backup + {:events [:profile/update-setting-from-backup]} + [{:keys [db]} {{:keys [name value]} :backedUpSettings}] + {:db (assoc-in db [:profile/profile (keyword name)] value)}) + +(rf/defn update-profile-from-backup + {:events [:profile/update-profile-from-backup]} + [_ {{:keys [ensUsernameDetails]} :backedUpProfile}] + {:dispatch [:ens/update-usernames ensUsernameDetails]})