diff --git a/src/messenger/android/core.cljs b/src/messenger/android/core.cljs index db02ccbca5..cc410e34c1 100644 --- a/src/messenger/android/core.cljs +++ b/src/messenger/android/core.cljs @@ -15,7 +15,7 @@ [messenger.android.chat :refer [chat]] [messenger.comm.pubsub :as pubsub] [messenger.comm.intercom :as intercom :refer [load-user-phone-number - load-user-whisper-identity]] + load-user-identity]] [messenger.protocol.protocol-handler :refer [make-handler]] [syng-im.protocol.api :refer [init-protocol]] [messenger.init :refer [init-simple-store]])) @@ -40,7 +40,7 @@ (defui AppRoot static om/IQuery (query [this] - '[:loading :contacts-ds :user-phone-number :confirmation-code]) + '[:loading :contacts-ds :user-phone-number :user-identity :confirmation-code]) Object (render [this] (navigator @@ -67,6 +67,6 @@ (pubsub/setup-pub-sub) (init-protocol (make-handler)) (load-user-phone-number) - (load-user-whisper-identity) + (load-user-identity) (om/add-root! state/reconciler AppRoot 1) (.registerComponent app-registry "Messenger" (fn [] app-root))) diff --git a/src/messenger/android/login.cljs b/src/messenger/android/login.cljs index 9ae0a965a3..68916e9483 100644 --- a/src/messenger/android/login.cljs +++ b/src/messenger/android/login.cljs @@ -28,7 +28,7 @@ (swap! state/app-state assoc :loading true) (let [app-state (state/state) phone-number (:user-phone-number app-state) - whisper-identity (:user-whisper-identity app-state)] + whisper-identity (:public (:user-identity app-state))] (intercom/sign-up phone-number whisper-identity show-confirm-view))) (defn update-phone-number [value] @@ -38,10 +38,10 @@ (defui Login static om/IQuery (query [this] - '[:user-phone-number :user-whisper-identity :loading]) + '[:user-phone-number :user-identity :loading]) Object (render [this] - (let [{:keys [user-phone-number user-whisper-identity loading]} (om/props this) + (let [{:keys [user-phone-number user-identity loading]} (om/props this) {:keys [nav]} (om/get-computed this)] (reset! nav-atom nav) (view diff --git a/src/messenger/android/sign_up_confirm.cljs b/src/messenger/android/sign_up_confirm.cljs index fc48094c6e..a01810c036 100644 --- a/src/messenger/android/sign_up_confirm.cljs +++ b/src/messenger/android/sign_up_confirm.cljs @@ -7,7 +7,6 @@ [natal-shell.alert :refer [alert]]) (:require [om.next :as om :refer-macros [defui]] [re-natal.support :as sup] - [syng-im.protocol.web3 :as whisper] [messenger.state :as state] [messenger.utils.utils :refer [log toast]] [messenger.utils.resources :as res] diff --git a/src/messenger/comm/intercom.cljs b/src/messenger/comm/intercom.cljs index 0c6cd1370c..5dccdf7cd6 100644 --- a/src/messenger/comm/intercom.cljs +++ b/src/messenger/comm/intercom.cljs @@ -22,8 +22,8 @@ ;; :service [service_name action_id args_map] (publish! :service [:user-data :user-data/load-phone-number nil])) -(defn load-user-whisper-identity [] - (publish! :service [:user-data :user-data/load-whisper-identity nil])) +(defn load-user-identity [] + (publish! :service [:user-data :user-data/load-identity nil])) (defn set-confirmation-code [confirmation-code] (publish! :service [:user-data :user-data/set-confirmation-code confirmation-code])) diff --git a/src/messenger/models/user_data.cljs b/src/messenger/models/user_data.cljs index a1175856b0..f61b712c12 100644 --- a/src/messenger/models/user_data.cljs +++ b/src/messenger/models/user_data.cljs @@ -6,8 +6,6 @@ [messenger.state :as state] [messenger.utils.utils :refer [log on-error toast]])) -(def ethereum-rpc-url "http://localhost:8545") - (defn set-phone-number [phone-number] (swap! state/app-state assoc :user-phone-number phone-number)) @@ -23,33 +21,8 @@ (swap! state/app-state assoc :user-phone-number (when value (str value))))))) -(defn save-whisper-identity [identity] - (set-item "user-whisper-identity" identity) - (swap! state/app-state assoc :user-whisper-identity identity)) - -(defn load-whisper-identity [] - (let [ch (chan)] - (get-item "user-whisper-identity" - (fn [error value] - (log (str "load whisper identity: " value)) - (put! ch - {:error error - :value (let [whisper-identity (when value (str value))] - (swap! state/app-state assoc :user-whisper-identity - whisper-identity) - whisper-identity)}))) - ch)) - -(defn new-whisper-identity [] - (let [ch (chan)] - (let [web3 (web3/make-web3 ethereum-rpc-url)] - (.newIdentity (web3/whisper web3) - (fn [error value] - (log (str "new whisper identity: " value)) - (swap! state/app-state assoc :user-whisper-identity value) - (put! ch {:error error - :value value})))) - ch)) +(defn set-identity [identity] + (swap! state/app-state assoc :user-identity identity)) (defn set-confirmation-code [code] (swap! state/app-state assoc :confirmation-code code)) diff --git a/src/messenger/services/user_data.cljs b/src/messenger/services/user_data.cljs index c51f42dd39..9a5bf143c1 100644 --- a/src/messenger/services/user_data.cljs +++ b/src/messenger/services/user_data.cljs @@ -4,10 +4,9 @@ [messenger.models.user-data :refer [set-phone-number save-phone-number load-phone-number - save-whisper-identity - load-whisper-identity - new-whisper-identity + set-identity set-confirmation-code]] + [messenger.models.protocol :refer [current-identity]] [messenger.utils.utils :refer [log on-error]] [syng-im.utils.logging :as log])) @@ -29,18 +28,11 @@ (log/debug "handling " id "args = " args) (load-phone-number)) -(defmethod user-data :user-data/load-whisper-identity +(defmethod user-data :user-data/load-identity [state id args] (log/info "handling " id " args = " args) - (go - (let [result (