Skip to content

Commit

Permalink
[#15944] Set installation name on android device
Browse files Browse the repository at this point in the history
  • Loading branch information
rasom committed Jun 19, 2023
1 parent 472a013 commit f8a328d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
7 changes: 7 additions & 0 deletions src/status_im/pairing/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
32 changes: 24 additions & 8 deletions src/status_im2/contexts/onboarding/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f8a328d

Please sign in to comment.