From f8a328d9043897dde37bdad7a0c6e4db93c0fe13 Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Mon, 19 Jun 2023 12:48:29 +0200 Subject: [PATCH] [#15944] Set installation name on android device --- src/status_im/pairing/core.cljs | 7 ++++ .../contexts/onboarding/events.cljs | 32 ++++++++++++++----- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/status_im/pairing/core.cljs b/src/status_im/pairing/core.cljs index 6bd1f3cbedcb..5f8852848151 100644 --- a/src/status_im/pairing/core.cljs +++ b/src/status_im/pairing/core.cljs @@ -30,6 +30,13 @@ :on-success on-success :on-error on-error})) +(defn set-installation-name-rpc + [installation-id name on-success on-error] + (json-rpc/call {:method "wakuext_setInstallationName" + :params [installation-id name] + :on-success on-success + :on-error on-error})) + (defn get-our-installations-rpc [on-success on-error] (json-rpc/call {:method "wakuext_getOurInstallations" diff --git a/src/status_im2/contexts/onboarding/events.cljs b/src/status_im2/contexts/onboarding/events.cljs index da38f97fdad3..e69c9238a5e4 100644 --- a/src/status_im2/contexts/onboarding/events.cljs +++ b/src/status_im2/contexts/onboarding/events.cljs @@ -7,10 +7,13 @@ [status-im.utils.types :as types] [status-im2.config :as config] [status-im2.constants :as constants] + [react-native.platform :as platform] [taoensso.timbre :as log] [utils.i18n :as i18n] [utils.re-frame :as rf] - [utils.security.core :as security])) + [utils.security.core :as security] + [status-im2.contexts.syncing.device.view :as device] + [status-im.pairing.core :as pairing])) (re-frame/reg-fx :multiaccount/create-account-and-login @@ -33,6 +36,18 @@ (fn [request] (native-module/restore-account-and-login request))) +(re-frame/reg-fx + :multiaccount/set-installation-name + (fn [installation-id] + (when platform/android? + (let [{:keys [model device-id]} (native-module/get-device-model-info) + device-name (string/join " " [model device-id])] + (pairing/set-installation-name-rpc + installation-id + device-name + #(log/debug "Installation name updated" device-name) + #(log/error "Error on installation name update" %)))))) + (rf/defn profile-data-set {:events [:onboarding-2/profile-data-set]} [{:keys [db]} onboarding-data] @@ -166,13 +181,14 @@ (rf/defn onboarding-new-account-finalize-setup {:events [:onboarding-2/finalize-setup]} [{:keys [db]}] - (let [masked-password (get-in db [:onboarding-2/profile :password]) - key-uid (get-in db [:multiaccount :key-uid]) - biometric-enabled? (= - constants/auth-method-biometric - (get-in db [:onboarding-2/profile :auth-method]))] - - (cond-> {:dispatch [:navigate-to :identifiers]} + (let [masked-password (get-in db [:onboarding-2/profile :password]) + {:keys [installation-id key-uid]} (get db :multiaccount) + biometric-enabled? (= + constants/auth-method-biometric + (get-in db [:onboarding-2/profile :auth-method]))] + + (cond-> {:dispatch [:navigate-to :identifiers] + :multiaccount/set-installation-name installation-id} biometric-enabled? (assoc :biometric/enable-and-save-password {:key-uid key-uid