[perf] network module
This commit is contained in:
parent
2204ad5142
commit
908f730b1d
37
project.clj
37
project.clj
|
@ -123,7 +123,16 @@
|
|||
:language-out :es-2015
|
||||
:modules {:cljs-base {:output-to "index.ios.js"}
|
||||
:i18n {:entries #{"status_im.goog.i18n"}
|
||||
:output-to "status-modules/cljs/i18n-raw.js"}}}
|
||||
:output-to "status-modules/cljs/i18n-raw.js"}
|
||||
:network {:entries #{"status_im.network.ui.network_details.views"
|
||||
"status_im.network.ui.edit_network.views"
|
||||
"status_im.network.ui.edit_network.styles"
|
||||
"status_im.network.ui.views"
|
||||
"status_im.network.ui.styles"
|
||||
"status_im.network.events"
|
||||
"status_im.network.subs"
|
||||
"status_im.network.core"}
|
||||
:output-to "status-modules/cljs/network-raw.js"}}}
|
||||
:warning-handlers [status-im.utils.build/warning-handler]}
|
||||
:android
|
||||
{:source-paths ["components/src" "react-native/src/cljsjs" "react-native/src/mobile" "src" "env/prod" "prod"]
|
||||
|
@ -143,7 +152,16 @@
|
|||
:language-out :es-2015
|
||||
:modules {:cljs-base {:output-to "index.android.js"}
|
||||
:i18n {:entries #{"status_im.goog.i18n"}
|
||||
:output-to "status-modules/cljs/i18n-raw.js"}}}
|
||||
:output-to "status-modules/cljs/i18n-raw.js"}
|
||||
:network {:entries #{"status_im.network.ui.network_details.views"
|
||||
"status_im.network.ui.edit_network.views"
|
||||
"status_im.network.ui.edit_network.styles"
|
||||
"status_im.network.ui.views"
|
||||
"status_im.network.ui.styles"
|
||||
"status_im.network.events"
|
||||
"status_im.network.subs"
|
||||
"status_im.network.core"}
|
||||
:output-to "status-modules/cljs/network-raw.js"}}}
|
||||
:warning-handlers [status-im.utils.build/warning-handler]}
|
||||
:desktop
|
||||
{:source-paths ["components/src" "react-native/src/cljsjs" "react-native/src/desktop" "src" "env/prod" "prod"]
|
||||
|
@ -160,7 +178,16 @@
|
|||
:elide-asserts true
|
||||
:language-in :es-2015
|
||||
:language-out :es-2015
|
||||
:modules {:cljs-base {:output-to "index.desktop.js"}
|
||||
:i18n {:entries #{"status_im.goog.i18n"}
|
||||
:output-to "status-modules/cljs/i18n-raw.js"}}}
|
||||
:modules {:cljs-base {:output-to "index.desktop.js"}
|
||||
:i18n {:entries #{"status_im.goog.i18n"}
|
||||
:output-to "status-modules/cljs/i18n-raw.js"}
|
||||
:network {:entries #{"status_im.network.ui.network_details.views"
|
||||
"status_im.network.ui.edit_network.views"
|
||||
"status_im.network.ui.edit_network.styles"
|
||||
"status_im.network.ui.views"
|
||||
"status_im.network.ui.styles"
|
||||
"status_im.network.events"
|
||||
"status_im.network.subs"
|
||||
"status_im.network.core"}
|
||||
:output-to "status-modules/cljs/network-raw.js"}}}
|
||||
:warning-handlers [status-im.utils.build/warning-handler]}}}}})
|
||||
|
|
|
@ -1,32 +1,14 @@
|
|||
(ns status-im.accounts.db
|
||||
(:require status-im.utils.db
|
||||
status-im.ui.screens.network-settings.db
|
||||
status-im.network.module
|
||||
status-im.ui.screens.bootnodes-settings.db
|
||||
status-im.ui.screens.extensions.db
|
||||
[clojure.string :as string]
|
||||
[cljs.spec.alpha :as spec]
|
||||
[status-im.constants :as const]
|
||||
[status-im.utils.security :as security]))
|
||||
|
||||
(defn logged-in? [cofx]
|
||||
(boolean
|
||||
(get-in cofx [:db :account/account])))
|
||||
|
||||
(defn credentials [cofx]
|
||||
(select-keys (get-in cofx [:db :accounts/login]) [:address :password :save-password?]))
|
||||
[status-im.constants :as const]))
|
||||
|
||||
(defn valid-length? [password]
|
||||
(>= (count password) const/min-password-length))
|
||||
|
||||
(defn account-creation-next-enabled? [{:keys [step password password-confirm name]}]
|
||||
(or (and password (= :enter-password step) (spec/valid? ::password (security/safe-unmask-data password)))
|
||||
(and password-confirm (= :confirm-password step) (spec/valid? ::password password-confirm))
|
||||
(and name (= :enter-name step) (not (string/blank? name)))))
|
||||
|
||||
(defn current-public-key
|
||||
[cofx]
|
||||
(get-in cofx [:db :account/account :public-key]))
|
||||
|
||||
(spec/def ::password (spec/and :global/not-empty-string valid-length?))
|
||||
|
||||
(spec/def :account/address :global/address)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
(ns status-im.accounts.login.core
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.accounts.db :as accounts.db]
|
||||
[status-im.accounts.model :as accounts.model]
|
||||
[status-im.chaos-mode.core :as chaos-mode]
|
||||
[status-im.data-store.core :as data-store]
|
||||
[status-im.ethereum.subscriptions :as ethereum.subscriptions]
|
||||
|
@ -80,7 +80,7 @@
|
|||
(get-in [:db :hardwallet :account])
|
||||
(select-keys [:whisper-private-key :encryption-public-key])
|
||||
(assoc :on-result #(re-frame/dispatch [:accounts.login.callback/login-success %])))}
|
||||
(let [{:keys [address password]} (accounts.db/credentials cofx)]
|
||||
(let [{:keys [address password]} (accounts.model/credentials cofx)]
|
||||
{:accounts.login/login [address password]})))
|
||||
|
||||
(fx/defn initialize-wallet [cofx]
|
||||
|
@ -94,7 +94,7 @@
|
|||
(fx/defn user-login-without-creating-db
|
||||
{:events [:accounts.login.ui/password-input-submitted]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [{:keys [address password]} (accounts.db/credentials cofx)]
|
||||
(let [{:keys [address password]} (accounts.model/credentials cofx)]
|
||||
(fx/merge
|
||||
cofx
|
||||
{:db (-> db
|
||||
|
@ -108,7 +108,7 @@
|
|||
|
||||
(fx/defn user-login
|
||||
[{:keys [db] :as cofx} create-database?]
|
||||
(let [{:keys [address password]} (accounts.db/credentials cofx)]
|
||||
(let [{:keys [address password]} (accounts.model/credentials cofx)]
|
||||
(fx/merge
|
||||
cofx
|
||||
{:db (-> db
|
||||
|
@ -147,7 +147,7 @@
|
|||
error (:error data)
|
||||
success (empty? error)
|
||||
{:keys [address password save-password?]}
|
||||
(accounts.db/credentials cofx)
|
||||
(accounts.model/credentials cofx)
|
||||
network-type (:network/type db)]
|
||||
;; check if logged into account
|
||||
(when address
|
||||
|
@ -208,7 +208,7 @@
|
|||
(show-migration-error-dialog cofx realm-error)
|
||||
|
||||
:database-does-not-exist
|
||||
(let [{:keys [address password]} (accounts.db/credentials cofx)]
|
||||
(let [{:keys [address password]} (accounts.model/credentials cofx)]
|
||||
{:data-store/change-account [address
|
||||
password
|
||||
true
|
||||
|
@ -251,7 +251,7 @@
|
|||
(fx/defn unknown-realm-error
|
||||
[cofx {:keys [realm-error erase-button]}]
|
||||
(let [{:keys [message]} realm-error
|
||||
{:keys [address]} (accounts.db/credentials cofx)]
|
||||
{:keys [address]} (accounts.model/credentials cofx)]
|
||||
{:ui/show-confirmation
|
||||
{:title (i18n/label :unknown-realm-error)
|
||||
:content (i18n/label
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
(ns status-im.accounts.model
|
||||
(:require [status-im.utils.security :as security]
|
||||
[cljs.spec.alpha :as spec]
|
||||
[clojure.string :as string]))
|
||||
|
||||
(defn logged-in? [cofx]
|
||||
(boolean
|
||||
(get-in cofx [:db :account/account])))
|
||||
|
||||
(defn credentials [cofx]
|
||||
(select-keys (get-in cofx [:db :accounts/login]) [:address :password :save-password?]))
|
||||
|
||||
(defn account-creation-next-enabled? [{:keys [step password password-confirm name]}]
|
||||
(or (and password (= :enter-password step) (spec/valid? :status-im.accounts.db/password (security/safe-unmask-data password)))
|
||||
(and password-confirm (= :confirm-password step) (spec/valid? :status-im.accounts.db/password password-confirm))
|
||||
(and name (= :enter-name step) (not (string/blank? name)))))
|
||||
|
||||
(defn current-public-key
|
||||
[cofx]
|
||||
(get-in cofx [:db :account/account :public-key]))
|
|
@ -1,6 +1,6 @@
|
|||
(ns status-im.chat.models
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.accounts.db :as accounts.db]
|
||||
[status-im.accounts.model :as accounts.model]
|
||||
[status-im.contact-code.core :as contact-code]
|
||||
[status-im.contact.core :as contact.core]
|
||||
[status-im.data-store.chats :as chats-store]
|
||||
|
@ -228,7 +228,7 @@
|
|||
(fx/defn mark-messages-seen
|
||||
"Marks all unviewed loaded messages as seen in particular chat"
|
||||
[{:keys [db] :as cofx} chat-id]
|
||||
(let [public-key (accounts.db/current-public-key cofx)
|
||||
(let [public-key (accounts.model/current-public-key cofx)
|
||||
loaded-unviewed-ids (get-in db [:chats chat-id :loaded-unviewed-messages-ids])]
|
||||
(when (seq loaded-unviewed-ids)
|
||||
(fx/merge cofx
|
||||
|
@ -279,7 +279,7 @@
|
|||
"Start a chat, making sure it exists"
|
||||
[{:keys [db] :as cofx} chat-id opts]
|
||||
;; don't allow to open chat with yourself
|
||||
(when (not= (accounts.db/current-public-key cofx) chat-id)
|
||||
(when (not= (accounts.model/current-public-key cofx) chat-id)
|
||||
(if config/use-status-go-protocol?
|
||||
(fx/merge cofx
|
||||
{:json-rpc/call [{:method "status_startOneOnOneChat"
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
(ns status-im.chat.models.loading
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.accounts.db :as accounts.db]
|
||||
[status-im.chat.commands.core :as commands]
|
||||
[status-im.chat.models :as chat-model]
|
||||
[status-im.mailserver.core :as mailserver]
|
||||
|
@ -125,7 +124,6 @@
|
|||
referenced-messages (into empty-message-map
|
||||
(get-referenced-messages (get-referenced-ids indexed-messages)))
|
||||
new-message-ids (keys indexed-messages)
|
||||
public-key (accounts.db/current-public-key cofx)
|
||||
loaded-unviewed-messages (get-unviewed-message-ids)]
|
||||
(fx/merge cofx
|
||||
{:db (-> db
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
(ns status-im.chat.models.message
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.accounts.db :as accounts.db]
|
||||
[status-im.accounts.model :as accounts.model]
|
||||
[status-im.chat.commands.receiving :as commands-receiving]
|
||||
[status-im.chat.db :as chat.db]
|
||||
[status-im.chat.models :as chat-model]
|
||||
|
@ -102,7 +102,7 @@
|
|||
[{:keys [db] :as cofx}
|
||||
{{:keys [chat-id message-id clock-value timestamp from] :as message} :message
|
||||
:keys [current-chat? batch? dedup-id raw-message]}]
|
||||
(let [current-public-key (accounts.db/current-public-key cofx)
|
||||
(let [current-public-key (accounts.model/current-public-key cofx)
|
||||
prepared-message (-> message
|
||||
(prepare-message chat-id current-chat?)
|
||||
(add-outgoing-status current-public-key))]
|
||||
|
@ -156,7 +156,7 @@
|
|||
old-id->message
|
||||
{:keys [from message-id chat-id js-obj content dedup-id] :as raw-message}]
|
||||
(let [{:keys [web3 current-chat-id view-id]} db
|
||||
current-public-key (accounts.db/current-public-key cofx)
|
||||
current-public-key (accounts.model/current-public-key cofx)
|
||||
current-chat? (and (or (= :chat view-id)
|
||||
(= :chat-modal view-id))
|
||||
(= current-chat-id chat-id))
|
||||
|
@ -216,11 +216,11 @@
|
|||
;; Version 0 does not have a concept of joining, so any message is ok
|
||||
;; otherwise check we joined
|
||||
(or (= 0 (get-in cofx [:db :chats chat-id :group-chat-local-version]))
|
||||
(get-in cofx [:db :chats chat-id :members-joined (accounts.db/current-public-key cofx)])))) chat-id
|
||||
(get-in cofx [:db :chats chat-id :members-joined (accounts.model/current-public-key cofx)])))) chat-id
|
||||
(and (= :public-group-user-message message-type)
|
||||
(get-in cofx [:db :chats chat-id :public?])) chat-id
|
||||
(and (= :user-message message-type)
|
||||
(= (accounts.db/current-public-key cofx) from)) chat-id
|
||||
(= (accounts.model/current-public-key cofx) from)) chat-id
|
||||
(= :user-message message-type) from))
|
||||
|
||||
(defn calculate-unviewed-messages-count
|
||||
|
@ -228,7 +228,7 @@
|
|||
(let [{:keys [current-chat-id view-id]} db
|
||||
chat-view? (or (= :chat view-id)
|
||||
(= :chat-modal view-id))
|
||||
current-public-key (accounts.db/current-public-key cofx)]
|
||||
current-public-key (accounts.model/current-public-key cofx)]
|
||||
(+ (get-in db [:chats chat-id :unviewed-messages-count])
|
||||
(if (and chat-view? (= current-chat-id chat-id))
|
||||
0
|
||||
|
@ -381,7 +381,7 @@
|
|||
[cofx chat-id message-id fcm-tokens status]
|
||||
(log/debug "#6772 - send-push-notification" message-id fcm-tokens)
|
||||
(when (and (seq fcm-tokens) (= status :sent))
|
||||
(let [payload {:from (accounts.db/current-public-key cofx)
|
||||
(let [payload {:from (accounts.model/current-public-key cofx)
|
||||
:to chat-id
|
||||
:id message-id}]
|
||||
{:send-notification {:data-payload (notifications/encode-notification-payload payload)
|
||||
|
@ -444,7 +444,7 @@
|
|||
(let [{:keys [chats]} db
|
||||
{:keys [last-clock-value] :as chat} (get chats chat-id)
|
||||
message-data (-> message
|
||||
(assoc :from (accounts.db/current-public-key cofx)
|
||||
(assoc :from (accounts.model/current-public-key cofx)
|
||||
:timestamp now
|
||||
:whisper-timestamp (quot now 1000)
|
||||
:clock-value (utils.clocks/send
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
(ns status-im.contact.core
|
||||
(:require [status-im.accounts.db :as accounts.db]
|
||||
(:require [status-im.accounts.model :as accounts.model]
|
||||
[status-im.contact-code.core :as contact-code]
|
||||
[status-im.contact.db :as contact.db]
|
||||
[status-im.contact.device-info :as device-info]
|
||||
|
@ -119,7 +119,7 @@
|
|||
;; for now
|
||||
(let [timestamp-ms (* timestamp 1000)
|
||||
prev-last-updated (get-in db [:contacts/contacts public-key :last-updated])
|
||||
current-public-key (accounts.db/current-public-key cofx)]
|
||||
current-public-key (accounts.model/current-public-key cofx)]
|
||||
(when (and (not= current-public-key public-key)
|
||||
(< prev-last-updated timestamp-ms))
|
||||
(let [contact (get contacts public-key)
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
[status-im.transport.message.public-chat :as transport.public-chat]
|
||||
[status-im.data-store.accounts :as data-store.accounts]
|
||||
[status-im.transport.chat.core :as transport.chat]
|
||||
[status-im.accounts.db :as accounts.db]
|
||||
[status-im.accounts.model :as accounts.model]
|
||||
[status-im.mailserver.core :as mailserver]))
|
||||
|
||||
(defn topic [pk]
|
||||
|
@ -42,7 +42,7 @@
|
|||
"We can stop listening to contact codes when we don't have any active chat
|
||||
with the user (one-to-one or group-chat), and it is not in our contacts"
|
||||
[{:keys [db] :as cofx} their-public-key]
|
||||
(let [my-public-key (accounts.db/current-public-key cofx)
|
||||
(let [my-public-key (accounts.model/current-public-key cofx)
|
||||
active-group-chats (filter (fn [{:keys [is-active members members-joined]}]
|
||||
(and is-active
|
||||
(contains? members-joined my-public-key)
|
||||
|
@ -64,11 +64,11 @@
|
|||
|
||||
(fx/defn init [cofx]
|
||||
(log/debug "initializing contact-code")
|
||||
(let [current-public-key (accounts.db/current-public-key cofx)]
|
||||
(let [current-public-key (accounts.model/current-public-key cofx)]
|
||||
(listen cofx current-public-key)))
|
||||
|
||||
(defn publish! [{:keys [web3 now] :as cofx}]
|
||||
(let [current-public-key (accounts.db/current-public-key cofx)
|
||||
(let [current-public-key (accounts.model/current-public-key cofx)
|
||||
chat-id (topic current-public-key)
|
||||
peers-count (:peers-count @re-frame.db/app-db)
|
||||
last-published (get-in
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
[status-im.data-store.contact-recovery :as data-store.contact-recovery]
|
||||
[status-im.utils.config :as config]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.accounts.db :as accounts.db]
|
||||
[status-im.accounts.model :as accounts.model]
|
||||
[status-im.contact.core :as models.contact]))
|
||||
|
||||
;; How long do we wait until we process a contact-recovery again?
|
||||
|
@ -25,7 +25,7 @@
|
|||
"Check that a contact-recovery for the given user is not already in process, if not
|
||||
fetch from db and check"
|
||||
[{:keys [db now] :as cofx} public-key]
|
||||
(let [my-public-key (accounts.db/current-public-key cofx)]
|
||||
(let [my-public-key (accounts.model/current-public-key cofx)]
|
||||
(when (and (not= public-key my-public-key)
|
||||
(not (get-in db [:contact-recovery/pop-up public-key])))
|
||||
{:db (update db :contact-recovery/pop-up conj public-key)
|
||||
|
@ -51,7 +51,7 @@
|
|||
"Send an empty message to the user, which will carry device information"
|
||||
[cofx public-key]
|
||||
(let [{:keys [web3]} (:db cofx)
|
||||
current-public-key (accounts.db/current-public-key cofx)]
|
||||
current-public-key (accounts.model/current-public-key cofx)]
|
||||
{:shh/send-direct-message
|
||||
[{:web3 web3
|
||||
:src current-public-key
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
[status-im.init.core :as init]
|
||||
[status-im.log-level.core :as log-level]
|
||||
[status-im.mailserver.core :as mailserver]
|
||||
[status-im.network.core :as network]
|
||||
[status-im.node.core :as node]
|
||||
[status-im.notifications.core :as notifications]
|
||||
[status-im.pairing.core :as pairing]
|
||||
|
@ -489,71 +488,6 @@
|
|||
(fn [cofx [_ request-id]]
|
||||
(mailserver/handle-request-success cofx request-id)))
|
||||
|
||||
;; network module
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:network.ui/save-network-pressed
|
||||
[(re-frame/inject-cofx :random-id-generator)]
|
||||
(fn [cofx]
|
||||
(network/save-network cofx)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:network.ui/input-changed
|
||||
(fn [cofx [_ input-key value]]
|
||||
(network/set-input cofx input-key value)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:network.ui/add-network-pressed
|
||||
(fn [cofx]
|
||||
(network/edit cofx)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:network.callback/non-rpc-network-saved
|
||||
(fn [_ _]
|
||||
{:ui/close-application nil}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:network.ui/save-non-rpc-network-pressed
|
||||
(fn [cofx [_ network]]
|
||||
(network/save-non-rpc-network cofx network)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:network.ui/save-rpc-network-pressed
|
||||
(fn [cofx [_ network]]
|
||||
(network/save-rpc-network cofx network)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:network.ui/remove-network-confirmed
|
||||
(fn [cofx [_ network]]
|
||||
(network/remove-network cofx network [:navigate-back])))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:network.ui/connect-network-pressed
|
||||
(fn [cofx [_ network-id]]
|
||||
(network/connect cofx {:network-id network-id
|
||||
:on-failure (fn [{:keys [reason]} _]
|
||||
(utils/show-popup "Error" (str reason)))})))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:network.ui/delete-network-pressed
|
||||
(fn [cofx [_ network]]
|
||||
(network/delete cofx {:network network})))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:network.ui/network-entry-pressed
|
||||
(fn [cofx [_ network]]
|
||||
(network/open-network-details cofx network)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:network/connection-status-changed
|
||||
(fn [{db :db :as cofx} [_ is-connected?]]
|
||||
(network/handle-connection-status-change cofx is-connected?)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:network/network-status-changed
|
||||
(fn [cofx [_ data]]
|
||||
(network/handle-network-status-change cofx data)))
|
||||
|
||||
;; fleet module
|
||||
|
||||
(handlers/register-handler-fx
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
(ns status-im.extensions.capacities.network
|
||||
(:require [status-im.utils.handlers :as handlers]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.network.core :as network]))
|
||||
[status-im.network.module :as network]))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:extensions/network-on-success
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
[clojure.spec.alpha :as spec]
|
||||
[clojure.string :as string]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.accounts.db :as accounts.db]
|
||||
[status-im.accounts.model :as accounts.model]
|
||||
[status-im.chat.models :as models.chat]
|
||||
[status-im.chat.models.message :as models.message]
|
||||
[status-im.contact.core :as models.contact]
|
||||
|
@ -120,7 +120,7 @@
|
|||
members (clojure.set/union (get-in cofx [:db :chats chat-id :contacts])
|
||||
removed-members)
|
||||
{:keys [web3]} (:db cofx)
|
||||
current-public-key (accounts.db/current-public-key cofx)
|
||||
current-public-key (accounts.model/current-public-key cofx)
|
||||
;; If a member has joined is listening to the shared topic and we send there
|
||||
;; to ourselves we send always on contact-discovery to make sure all devices
|
||||
;; are informed, in case of dropped messages.
|
||||
|
@ -202,7 +202,7 @@
|
|||
(fx/defn create
|
||||
"Format group update message and sign membership"
|
||||
[{:keys [db random-guid-generator] :as cofx} group-name]
|
||||
(let [my-public-key (accounts.db/current-public-key cofx)
|
||||
(let [my-public-key (accounts.model/current-public-key cofx)
|
||||
chat-id (str (random-guid-generator) my-public-key)
|
||||
selected-contacts (:group/selected-contacts db)
|
||||
clock-value (utils.clocks/send 0)
|
||||
|
@ -227,7 +227,7 @@
|
|||
(fx/defn remove-member
|
||||
"Format group update message and sign membership"
|
||||
[{:keys [db] :as cofx} chat-id member]
|
||||
(let [my-public-key (accounts.db/current-public-key cofx)
|
||||
(let [my-public-key (accounts.model/current-public-key cofx)
|
||||
last-clock-value (get-last-clock-value cofx chat-id)
|
||||
chat (get-in cofx [:db :chats chat-id])
|
||||
remove-event {:type "member-removed"
|
||||
|
@ -243,7 +243,7 @@
|
|||
(fx/defn join-chat
|
||||
"Format group update message and sign membership"
|
||||
[cofx chat-id]
|
||||
(let [my-public-key (accounts.db/current-public-key cofx)
|
||||
(let [my-public-key (accounts.model/current-public-key cofx)
|
||||
last-clock-value (get-last-clock-value cofx chat-id)
|
||||
chat (get-in cofx [:db :chats chat-id])
|
||||
event (member-joined-event last-clock-value my-public-key)]
|
||||
|
@ -264,7 +264,7 @@
|
|||
(fx/defn make-admin
|
||||
"Format group update with make admin message and sign membership"
|
||||
[{:keys [db] :as cofx} chat-id member]
|
||||
(let [my-public-key (accounts.db/current-public-key cofx)
|
||||
(let [my-public-key (accounts.model/current-public-key cofx)
|
||||
last-clock-value (get-last-clock-value cofx chat-id)
|
||||
chat (get-in cofx [:db :chats chat-id])
|
||||
event {:type "admins-added"
|
||||
|
@ -284,12 +284,12 @@
|
|||
events [(members-added-event last-clock-value selected-participants)]]
|
||||
|
||||
{:group-chats/sign-membership {:chat-id current-chat-id
|
||||
:from (accounts.db/current-public-key cofx)
|
||||
:from (accounts.model/current-public-key cofx)
|
||||
:events events}}))
|
||||
(fx/defn remove
|
||||
"Remove & leave chat"
|
||||
[{:keys [db] :as cofx} chat-id]
|
||||
(let [my-public-key (accounts.db/current-public-key cofx)]
|
||||
(let [my-public-key (accounts.model/current-public-key cofx)]
|
||||
(fx/merge cofx
|
||||
(remove-member chat-id my-public-key)
|
||||
(models.chat/remove-chat chat-id))))
|
||||
|
@ -463,7 +463,7 @@
|
|||
"Listen/Tear down the shared topic/contact-codes. Stop listening for members who
|
||||
have left the chat"
|
||||
[cofx chat-id previous-chat]
|
||||
(let [my-public-key (accounts.db/current-public-key cofx)
|
||||
(let [my-public-key (accounts.model/current-public-key cofx)
|
||||
new-chat (get-in cofx [:db :chats chat-id])]
|
||||
;; If we left the chat, teardown, otherwise upsert
|
||||
(if (and (group-chats.db/joined? my-public-key previous-chat)
|
||||
|
@ -495,7 +495,7 @@
|
|||
(let [previous-chat (get-in cofx [:db :chats chat-id])
|
||||
all-updates (clojure.set/union (set (:membership-updates previous-chat))
|
||||
(set (:membership-updates membership-update)))
|
||||
my-public-key (accounts.db/current-public-key cofx)
|
||||
my-public-key (accounts.model/current-public-key cofx)
|
||||
unwrapped-events (group-chats.db/unwrap-events all-updates)
|
||||
new-group (build-group unwrapped-events)
|
||||
member? (contains? (:contacts new-group) my-public-key)]
|
||||
|
@ -527,7 +527,7 @@
|
|||
[{:keys [db] :as cofx} {:keys [chat-id] :as signed-events}]
|
||||
(let [old-chat (get-in db [:chats chat-id])
|
||||
updated-chat (update old-chat :membership-updates conj signed-events)
|
||||
my-public-key (accounts.db/current-public-key cofx)
|
||||
my-public-key (accounts.model/current-public-key cofx)
|
||||
group-update (chat->group-update chat-id updated-chat)
|
||||
new-group-fx (handle-membership-update group-update nil my-public-key)
|
||||
;; We need to send to users who have been removed as well
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
(ns ^{:doc "Mailserver events and API"}
|
||||
status-im.mailserver.core
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.accounts.db :as accounts.db]
|
||||
[status-im.accounts.model :as accounts.model]
|
||||
[status-im.fleet.core :as fleet]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.utils.platform :as platform]
|
||||
|
@ -504,7 +504,7 @@
|
|||
"when host reconnects, reset request-to and
|
||||
reconnect to mailserver"
|
||||
[{:keys [db] :as cofx} is-connected?]
|
||||
(when (and (accounts.db/logged-in? cofx)
|
||||
(when (and (accounts.model/logged-in? cofx)
|
||||
is-connected?)
|
||||
(fx/merge cofx
|
||||
(reset-request-to)
|
||||
|
@ -813,7 +813,7 @@
|
|||
(fx/defn handle-request-completed
|
||||
[{{:keys [chats]} :db :as cofx}
|
||||
{:keys [requestID lastEnvelopeHash cursor errorMessage]}]
|
||||
(when (accounts.db/logged-in? cofx)
|
||||
(when (accounts.model/logged-in? cofx)
|
||||
(if (empty? errorMessage)
|
||||
(let [never-synced-chats-in-request
|
||||
(->> (chats->never-synced-public-chats chats)
|
||||
|
@ -908,7 +908,7 @@
|
|||
(fx/defn fetch-history
|
||||
[{:keys [db] :as cofx} chat-id {:keys [from to]}]
|
||||
(log/debug "fetch-history" "chat-id:" chat-id "from-timestamp:" from)
|
||||
(let [public-key (accounts.db/current-public-key cofx)
|
||||
(let [public-key (accounts.model/current-public-key cofx)
|
||||
topic (or (get-in db [:transport/chats chat-id :topic])
|
||||
(transport.topic/public-key->discovery-topic-hash public-key))]
|
||||
(fx/merge cofx
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
(ns status-im.models.dev-server
|
||||
(:require [clojure.string :as string]
|
||||
[status-im.browser.core :as browser]
|
||||
[status-im.network.core :as network]
|
||||
[status-im.network.module :as network]
|
||||
[status-im.utils.fx :as fx]))
|
||||
|
||||
(defn start
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
[status-im.i18n :as i18n]
|
||||
[status-im.mailserver.core :as mailserver]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.network.net-info :as net-info]
|
||||
[status-im.ui.screens.mobile-network-settings.events :as mobile-network]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.utils.handlers :as handlers]
|
||||
[status-im.utils.http :as http]
|
||||
[status-im.utils.types :as types]))
|
||||
[status-im.utils.types :as types]
|
||||
status-im.network.subs))
|
||||
|
||||
(def url-regex
|
||||
#"https?://(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}(\.[a-z]{2,6})?\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)")
|
||||
|
@ -245,12 +245,6 @@
|
|||
{:data (get-in cofx [:db :networks/manage])
|
||||
:success-event [:navigate-back]}))
|
||||
|
||||
(fx/defn handle-connection-status-change
|
||||
[{:keys [db] :as cofx} is-connected?]
|
||||
(fx/merge cofx
|
||||
{:db (assoc db :network-status (if is-connected? :online :offline))}
|
||||
(mailserver/network-connection-status-changed is-connected?)))
|
||||
|
||||
(defn- navigate-to-network-details
|
||||
[cofx network show-warning?]
|
||||
(fx/merge cofx
|
||||
|
@ -275,33 +269,3 @@
|
|||
;; Otherwise, we show an explanation dialog to a user if the current fleet does not suport LES
|
||||
{:utils/show-popup {:title "LES not supported"
|
||||
:content (not-supported-warning fleet)}})))
|
||||
|
||||
(fx/defn handle-network-status-change
|
||||
[{:keys [db] :as cofx} {:keys [type] :as data}]
|
||||
(let [old-network-type (:network/type db)]
|
||||
(fx/merge
|
||||
cofx
|
||||
{:db (assoc db :network/type type)
|
||||
:network/notify-status-go data}
|
||||
(when (= "none" old-network-type)
|
||||
(chaos-mode/check-chaos-mode))
|
||||
(mobile-network/on-network-status-change))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:network/listen-to-network-status
|
||||
(fn []
|
||||
(let [callback-event #(re-frame/dispatch [:network/network-status-changed %])]
|
||||
(net-info/net-info callback-event)
|
||||
(net-info/add-net-info-listener callback-event))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:network/listen-to-connection-status
|
||||
(fn []
|
||||
(let [callback-event #(re-frame/dispatch [:network/connection-status-changed %])]
|
||||
(net-info/is-connected? callback-event)
|
||||
(net-info/add-connection-listener callback-event))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:network/notify-status-go
|
||||
(fn [data]
|
||||
(status/connection-change data)))
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
(ns status-im.network.events
|
||||
(:require [status-im.network.core :as network]
|
||||
[status-im.utils.handlers :as handlers]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.utils.utils :as utils]))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:network.ui/save-network-pressed
|
||||
[(re-frame/inject-cofx :random-id-generator)]
|
||||
(fn [cofx]
|
||||
(network/save-network cofx)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:network.ui/input-changed
|
||||
(fn [cofx [_ input-key value]]
|
||||
(network/set-input cofx input-key value)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:network.ui/add-network-pressed
|
||||
(fn [cofx]
|
||||
(network/edit cofx)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:network.callback/non-rpc-network-saved
|
||||
(fn [_ _]
|
||||
{:ui/close-application nil}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:network.ui/save-non-rpc-network-pressed
|
||||
(fn [cofx [_ network]]
|
||||
(network/save-non-rpc-network cofx network)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:network.ui/save-rpc-network-pressed
|
||||
(fn [cofx [_ network]]
|
||||
(network/save-rpc-network cofx network)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:network.ui/remove-network-confirmed
|
||||
(fn [cofx [_ network]]
|
||||
(network/remove-network cofx network [:navigate-back])))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:network.ui/connect-network-pressed
|
||||
(fn [cofx [_ network-id]]
|
||||
(network/connect cofx {:network-id network-id
|
||||
:on-failure (fn [{:keys [reason]} _]
|
||||
(utils/show-popup "Error" (str reason)))})))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:network.ui/delete-network-pressed
|
||||
(fn [cofx [_ network]]
|
||||
(network/delete cofx {:network network})))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:network.ui/network-entry-pressed
|
||||
(fn [cofx [_ network]]
|
||||
(network/open-network-details cofx network)))
|
|
@ -0,0 +1,52 @@
|
|||
(ns status-im.network.module
|
||||
(:require-macros [status-im.modules :as modules])
|
||||
(:require status-im.network.net-info
|
||||
status-im.network.ui.db
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.ethereum.core :as ethereum]))
|
||||
|
||||
(modules/defmodule network
|
||||
{:save 'status-im.network.core/save
|
||||
:connect 'status-im.network.core/connect
|
||||
:delete 'status-im.network.core/delete
|
||||
:get-network-id-for-chain-id 'status-im.network.core/get-network-id-for-chain-id
|
||||
:get-network 'status-im.network.core/get-network
|
||||
:remove-network 'status-im.network.core/remove-network
|
||||
:edit-network-view 'status-im.network.ui.edit-network.views/edit-network
|
||||
:network-settings-view 'status-im.network.ui.views/network-settings
|
||||
:network-details-view 'status-im.network.ui.network-details.views/network-details})
|
||||
|
||||
(defn save [& args]
|
||||
(apply (get-symbol :save) args))
|
||||
|
||||
(defn connect [& args]
|
||||
(apply (get-symbol :connect) args))
|
||||
|
||||
(defn delete [& args]
|
||||
(apply (get-symbol :delete) args))
|
||||
|
||||
(defn get-network-id-for-chain-id [& args]
|
||||
(apply (get-symbol :get-network-id-for-chain-id) args))
|
||||
|
||||
(defn get-network [& args]
|
||||
(apply (get-symbol :get-network) args))
|
||||
|
||||
(defn remove-network [& args]
|
||||
(apply (get-symbol :remove-network) args))
|
||||
|
||||
(defn edit-network-view []
|
||||
[(get-symbol :edit-network-view)])
|
||||
|
||||
(defn network-settings-view []
|
||||
[(get-symbol :network-settings-view)])
|
||||
|
||||
(defn network-details-view []
|
||||
[(get-symbol :network-details-view)])
|
||||
|
||||
;; Preloaded handlers, subs, functions
|
||||
|
||||
(re-frame/reg-sub
|
||||
:get-network-id
|
||||
:<- [:network]
|
||||
(fn [network]
|
||||
(ethereum/network->chain-id network)))
|
|
@ -1,7 +1,14 @@
|
|||
(ns status-im.network.net-info
|
||||
(:require [taoensso.timbre :as log]
|
||||
[status-im.ui.components.react :as react-components]
|
||||
[status-im.utils.platform :as platform]))
|
||||
[status-im.utils.platform :as platform]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.mailserver.core :as mailserver]
|
||||
[status-im.utils.handlers :as handlers]
|
||||
[status-im.chaos-mode.core :as chaos-mode]
|
||||
[status-im.native-module.core :as status]
|
||||
[status-im.ui.screens.mobile-network-settings.events :as mobile-network]))
|
||||
|
||||
(defn is-connected? [callback]
|
||||
(when (react-components/net-info)
|
||||
|
@ -34,3 +41,49 @@
|
|||
(when (react-components/net-info)
|
||||
(.addEventListener (react-components/net-info) "connectionChange"
|
||||
(wrap-net-info listener))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:network/listen-to-network-status
|
||||
(fn []
|
||||
(let [callback-event #(re-frame/dispatch [:network/network-status-changed %])]
|
||||
(net-info callback-event)
|
||||
(add-net-info-listener callback-event))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:network/listen-to-connection-status
|
||||
(fn []
|
||||
(let [callback-event #(re-frame/dispatch [:network/connection-status-changed %])]
|
||||
(is-connected? callback-event)
|
||||
(add-connection-listener callback-event))))
|
||||
|
||||
(fx/defn handle-connection-status-change
|
||||
[{:keys [db] :as cofx} is-connected?]
|
||||
(fx/merge cofx
|
||||
{:db (assoc db :network-status (if is-connected? :online :offline))}
|
||||
(mailserver/network-connection-status-changed is-connected?)))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:network/connection-status-changed
|
||||
(fn [{db :db :as cofx} [_ is-connected?]]
|
||||
(handle-connection-status-change cofx is-connected?)))
|
||||
|
||||
(fx/defn handle-network-status-change
|
||||
[{:keys [db] :as cofx} {:keys [type] :as data}]
|
||||
(let [old-network-type (:network/type db)]
|
||||
(fx/merge
|
||||
cofx
|
||||
{:db (assoc db :network/type type)
|
||||
:network/notify-status-go data}
|
||||
(when (= "none" old-network-type)
|
||||
(chaos-mode/check-chaos-mode))
|
||||
(mobile-network/on-network-status-change))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:network/network-status-changed
|
||||
(fn [cofx [_ data]]
|
||||
(handle-network-status-change cofx data)))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:network/notify-status-go
|
||||
(fn [data]
|
||||
(status/connection-change data)))
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
(ns status-im.network.subs
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.ethereum.core :as ethereum]))
|
||||
|
||||
(defn- filter-networks [network-type]
|
||||
(fn [network]
|
||||
(let [chain-id (ethereum/network->chain-id network)
|
||||
testnet? (ethereum/testnet? chain-id)
|
||||
custom? (:custom? network)]
|
||||
(case network-type
|
||||
:custom custom?
|
||||
:mainnet (and (not custom?) (not testnet?))
|
||||
:testnet (and (not custom?) testnet?)))))
|
||||
|
||||
(defn- label-networks [default-networks]
|
||||
(fn [network]
|
||||
(let [custom? (not (contains? default-networks (:id network)))]
|
||||
(assoc network :custom? custom?))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:get-networks
|
||||
:<- [:account/account]
|
||||
:<- [:networks/networks]
|
||||
(fn [[{:keys [networks]} default-networks]]
|
||||
(let [networks (map (label-networks default-networks) (sort-by :name (vals networks)))
|
||||
types [:mainnet :testnet :custom]]
|
||||
(zipmap
|
||||
types
|
||||
(map #(filter (filter-networks %) networks) types)))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:get-manage-network
|
||||
:<- [:networks/manage]
|
||||
(fn [manage]
|
||||
manage))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:manage-network-valid?
|
||||
:<- [:get-manage-network]
|
||||
(fn [manage]
|
||||
(not-any? :error (vals manage))))
|
|
@ -1,4 +1,4 @@
|
|||
(ns status-im.ui.screens.network-settings.db
|
||||
(ns status-im.network.ui.db
|
||||
(:require [cljs.spec.alpha :as spec]))
|
||||
|
||||
(spec/def :networks/id string?)
|
|
@ -1,4 +1,4 @@
|
|||
(ns status-im.ui.screens.network-settings.edit-network.styles
|
||||
(ns status-im.network.ui.edit-network.styles
|
||||
(:require-macros [status-im.utils.styles :refer [defstyle]])
|
||||
(:require [status-im.ui.components.colors :as colors]
|
||||
[status-im.ui.components.styles :as styles]))
|
|
@ -1,4 +1,4 @@
|
|||
(ns status-im.ui.screens.network-settings.edit-network.views
|
||||
(ns status-im.network.ui.edit-network.views
|
||||
(:require-macros [status-im.utils.views :as views])
|
||||
(:require
|
||||
[re-frame.core :as re-frame]
|
||||
|
@ -10,7 +10,7 @@
|
|||
[status-im.ui.components.toolbar.view :as toolbar]
|
||||
[status-im.ui.components.list.views :as list]
|
||||
[status-im.ui.components.text-input.view :as text-input]
|
||||
[status-im.ui.screens.network-settings.edit-network.styles :as styles]
|
||||
[status-im.network.ui.edit-network.styles :as styles]
|
||||
[clojure.string :as string]))
|
||||
|
||||
(defn- render-network-type [manage-network type]
|
|
@ -1,4 +1,4 @@
|
|||
(ns status-im.ui.screens.network-settings.network-details.views
|
||||
(ns status-im.network.ui.network-details.views
|
||||
(:require-macros [status-im.utils.views :as views])
|
||||
(:require
|
||||
[re-frame.core :as rf]
|
||||
|
@ -8,8 +8,8 @@
|
|||
[status-im.i18n :as i18n]
|
||||
[status-im.ui.components.styles :as components.styles]
|
||||
[status-im.ui.components.common.common :as components.common]
|
||||
[status-im.ui.screens.network-settings.styles :as st]
|
||||
[status-im.ui.screens.network-settings.views :as network-settings]))
|
||||
[status-im.network.ui.styles :as st]
|
||||
[status-im.network.ui.views :as network-settings]))
|
||||
|
||||
(views/defview network-details []
|
||||
(views/letsubs [{:keys [networks/selected-network]} [:get-screen-params]
|
|
@ -1,4 +1,4 @@
|
|||
(ns status-im.ui.screens.network-settings.styles
|
||||
(ns status-im.network.ui.styles
|
||||
(:require-macros [status-im.utils.styles :refer [defstyle defnstyle]])
|
||||
(:require [status-im.ui.components.colors :as colors]
|
||||
[status-im.ui.components.styles :as components.styles]))
|
|
@ -1,7 +1,6 @@
|
|||
(ns status-im.ui.screens.network-settings.views
|
||||
(ns status-im.network.ui.views
|
||||
(:require-macros [status-im.utils.views :as views])
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[reagent.core :as reagent]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.ui.components.react :as react]
|
||||
[status-im.ui.components.icons.vector-icons :as vector-icons]
|
||||
|
@ -10,7 +9,7 @@
|
|||
[status-im.ui.components.toolbar.view :as toolbar]
|
||||
[status-im.ui.components.toolbar.actions :as toolbar.actions]
|
||||
[status-im.ui.components.styles :as components.styles]
|
||||
[status-im.ui.screens.network-settings.styles :as styles]))
|
||||
[status-im.network.ui.styles :as styles]))
|
||||
|
||||
(defn- network-icon [connected? size]
|
||||
[react/view (styles/network-icon connected? size)
|
|
@ -1,7 +1,11 @@
|
|||
(ns status-im.notifications.core
|
||||
(:require [goog.object :as object]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.accounts.db :as accounts.db]
|
||||
[status-im.react-native.js-dependencies :as rn]
|
||||
[taoensso.timbre :as log]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.accounts.model :as accounts.model]
|
||||
[status-im.contact.db :as contact.db]
|
||||
[status-im.chat.models :as chat-model]
|
||||
[status-im.contact.db :as contact.db]
|
||||
[status-im.ethereum.core :as ethereum]
|
||||
|
@ -96,7 +100,7 @@
|
|||
(if-let [account-pubkey (hash->pubkey contact-pubkey-or-hash
|
||||
(-> db :accounts/accounts vals))]
|
||||
account-pubkey
|
||||
(if (accounts.db/logged-in? cofx)
|
||||
(if (accounts.model/logged-in? cofx)
|
||||
;; TODO: for simplicity we're doing a linear lookup of the contacts,
|
||||
;; but we might want to build a map of hashed pubkeys to pubkeys
|
||||
;; for this purpose
|
||||
|
@ -145,7 +149,7 @@
|
|||
:id id})
|
||||
|
||||
(defn- get-contact-name [{:keys [db] :as cofx} from]
|
||||
(if (accounts.db/logged-in? cofx)
|
||||
(if (accounts.model/logged-in? cofx)
|
||||
(:name (hash->contact from (-> db :contacts/contacts vals)))
|
||||
(anonymize-pubkey from)))
|
||||
|
||||
|
@ -210,7 +214,7 @@
|
|||
"Ignore push notifications from unknown contacts or removed chats"
|
||||
[{:keys [db] :as cofx} {:keys [from] :as rehydrated-payload}]
|
||||
(and (valid-notification-payload? rehydrated-payload)
|
||||
(accounts.db/logged-in? cofx)
|
||||
(accounts.model/logged-in? cofx)
|
||||
(some #(= (:public-key %) from)
|
||||
(contact.db/get-active-contacts (:contacts/contacts db)))
|
||||
(some #(= (:chat-id %) from)
|
||||
|
@ -244,7 +248,7 @@
|
|||
|
||||
(fx/defn handle-push-notification-open
|
||||
[{:keys [db] :as cofx} decoded-payload {:keys [stored?] :as ctx}]
|
||||
(let [current-public-key (accounts.db/current-public-key cofx)
|
||||
(let [current-public-key (accounts.model/current-public-key cofx)
|
||||
nav-opts (when stored? {:navigation-reset? true})
|
||||
rehydrated-payload (rehydrate-payload cofx decoded-payload)
|
||||
from (:from rehydrated-payload)
|
||||
|
@ -334,7 +338,7 @@
|
|||
|
||||
(fx/defn process-stored-event [{:keys [db] :as cofx} address stored-pns]
|
||||
(when-not platform/desktop?
|
||||
(if (accounts.db/logged-in? cofx)
|
||||
(if (accounts.model/logged-in? cofx)
|
||||
(let [current-account (:account/account db)
|
||||
current-address (:address current-account)
|
||||
current-account-pubkey (:public-key current-account)
|
||||
|
|
|
@ -9,16 +9,12 @@
|
|||
[status-im.utils.config :as config]
|
||||
[status-im.utils.platform :as utils.platform]
|
||||
[status-im.chat.models :as models.chat]
|
||||
[status-im.transport.message.public-chat :as transport.public-chat]
|
||||
[status-im.accounts.db :as accounts.db]
|
||||
[status-im.accounts.model :as accounts.model]
|
||||
[status-im.transport.message.protocol :as protocol]
|
||||
[status-im.transport.utils :as transport.utils]
|
||||
[status-im.data-store.installations :as data-store.installations]
|
||||
[status-im.native-module.core :as native-module]
|
||||
[status-im.utils.identicon :as identicon]
|
||||
[status-im.contact.core :as contact]
|
||||
[status-im.contact-code.core :as contact-code]
|
||||
[status-im.data-store.contacts :as data-store.contacts]
|
||||
[status-im.data-store.accounts :as data-store.accounts]
|
||||
[status-im.transport.message.pairing :as transport.pairing]))
|
||||
|
||||
|
@ -49,7 +45,7 @@
|
|||
|
||||
(defn send-pair-installation [cofx payload]
|
||||
(let [{:keys [web3]} (:db cofx)
|
||||
current-public-key (accounts.db/current-public-key cofx)]
|
||||
current-public-key (accounts.model/current-public-key cofx)]
|
||||
{:shh/send-pairing-message {:web3 web3
|
||||
:src current-public-key
|
||||
:payload payload}}))
|
||||
|
@ -109,7 +105,7 @@
|
|||
:has-bundle? true}]
|
||||
(when
|
||||
(and (= (:identity bundle)
|
||||
(accounts.db/current-public-key cofx))
|
||||
(accounts.model/current-public-key cofx))
|
||||
(not= (get-in db [:account/account :installation-id]) installation-id)
|
||||
(not (get-in db [:pairing/installations installation-id])))
|
||||
(fx/merge cofx
|
||||
|
@ -214,7 +210,7 @@
|
|||
|
||||
(fx/defn send-sync-installation [cofx payload]
|
||||
(let [{:keys [web3]} (:db cofx)
|
||||
current-public-key (accounts.db/current-public-key cofx)]
|
||||
current-public-key (accounts.model/current-public-key cofx)]
|
||||
{:shh/send-direct-message
|
||||
[{:web3 web3
|
||||
:src current-public-key
|
||||
|
@ -278,7 +274,7 @@
|
|||
contacts))
|
||||
|
||||
(defn handle-sync-installation [{:keys [db] :as cofx} {:keys [contacts account chat]} sender]
|
||||
(if (= sender (accounts.db/current-public-key cofx))
|
||||
(if (= sender (accounts.model/current-public-key cofx))
|
||||
(let [success-event [:message/messages-persisted [(or (:dedup-id cofx) (:js-obj cofx))]]
|
||||
new-contacts (when (seq contacts)
|
||||
(vals (merge-contacts (:contacts/contacts db)
|
||||
|
@ -302,7 +298,7 @@
|
|||
fcm-token
|
||||
installation-id
|
||||
device-type]} timestamp sender]
|
||||
(if (and (= sender (accounts.db/current-public-key cofx))
|
||||
(if (and (= sender (accounts.model/current-public-key cofx))
|
||||
(not= (get-in db [:account/account :installation-id]) installation-id))
|
||||
(let [installation {:installation-id installation-id
|
||||
:name name
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
(ns status-im.signals.core
|
||||
(:require [status-im.accounts.db :as accounts.db]
|
||||
(:require [status-im.accounts.model :as accounts.model]
|
||||
[status-im.accounts.login.core :as accounts.login]
|
||||
[status-im.chat.models.loading :as chat.loading]
|
||||
[status-im.contact-recovery.core :as contact-recovery]
|
||||
|
@ -30,7 +30,7 @@
|
|||
:login
|
||||
(accounts.login/login)
|
||||
:verify-account
|
||||
(let [{:keys [address password]} (accounts.db/credentials cofx)]
|
||||
(let [{:keys [address password]} (accounts.model/credentials cofx)]
|
||||
(fn [_]
|
||||
{:accounts.login/verify
|
||||
[address password (:realm-error db)]}))
|
||||
|
@ -70,7 +70,7 @@
|
|||
"envelope.expired" (transport.message/update-envelope-status cofx (:hash event) :not-sent)
|
||||
"bundles.added" (pairing/handle-bundles-added cofx event)
|
||||
"mailserver.request.completed" (mailserver/handle-request-completed cofx event)
|
||||
"mailserver.request.expired" (when (accounts.db/logged-in? cofx)
|
||||
"mailserver.request.expired" (when (accounts.model/logged-in? cofx)
|
||||
(mailserver/resend-request cofx {:request-id (:hash event)}))
|
||||
"messages.decrypt.failed" (contact-recovery/handle-contact-recovery-fx cofx (:sender event))
|
||||
"discovery.summary" (summary cofx event)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
(:require [cljs.spec.alpha :as spec]
|
||||
[clojure.string :as string]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.accounts.model :as accounts.model]
|
||||
[status-im.accounts.db :as accounts.db]
|
||||
[status-im.browser.core :as browser]
|
||||
[status-im.chat.commands.core :as commands]
|
||||
|
@ -337,7 +338,7 @@
|
|||
:get-account-creation-next-enabled?
|
||||
:<- [:accounts/create]
|
||||
(fn [create]
|
||||
(accounts.db/account-creation-next-enabled? create)))
|
||||
(accounts.model/account-creation-next-enabled? create)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:account-settings
|
||||
|
@ -912,52 +913,6 @@
|
|||
{:search-filter search-filter
|
||||
:chats filtered-chats})))
|
||||
|
||||
;;NETWORK SETTINGS =====================================================================================================
|
||||
|
||||
(re-frame/reg-sub
|
||||
:get-network-id
|
||||
:<- [:network]
|
||||
(fn [network]
|
||||
(ethereum/network->chain-id network)))
|
||||
|
||||
(defn- filter-networks [network-type]
|
||||
(fn [network]
|
||||
(let [chain-id (ethereum/network->chain-id network)
|
||||
testnet? (ethereum/testnet? chain-id)
|
||||
custom? (:custom? network)]
|
||||
(case network-type
|
||||
:custom custom?
|
||||
:mainnet (and (not custom?) (not testnet?))
|
||||
:testnet (and (not custom?) testnet?)))))
|
||||
|
||||
(defn- label-networks [default-networks]
|
||||
(fn [network]
|
||||
(let [custom? (not (contains? default-networks (:id network)))]
|
||||
(assoc network :custom? custom?))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:get-networks
|
||||
:<- [:account/account]
|
||||
:<- [:networks/networks]
|
||||
(fn [[{:keys [networks] :as account} default-networks]]
|
||||
(let [networks (map (label-networks default-networks) (sort-by :name (vals networks)))
|
||||
types [:mainnet :testnet :custom]]
|
||||
(zipmap
|
||||
types
|
||||
(map #(filter (filter-networks %) networks) types)))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:get-manage-network
|
||||
:<- [:networks/manage]
|
||||
(fn [manage]
|
||||
manage))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:manage-network-valid?
|
||||
:<- [:get-manage-network]
|
||||
(fn [manage]
|
||||
(not-any? :error (vals manage))))
|
||||
|
||||
;;PAIRING ==============================================================================================================
|
||||
|
||||
(re-frame/reg-sub
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
(ns ^{:doc "Protocol API and protocol utils"}
|
||||
status-im.transport.message.protocol
|
||||
(:require [cljs.spec.alpha :as spec]
|
||||
[status-im.accounts.db :as accounts.db]
|
||||
[status-im.accounts.model :as accounts.model]
|
||||
[status-im.ethereum.core :as ethereum]
|
||||
[status-im.transport.db :as transport.db]
|
||||
[status-im.transport.partitioned-topic :as transport.topic]
|
||||
|
@ -43,7 +43,7 @@
|
|||
(let [{:keys [web3]} db]
|
||||
{:shh/send-public-message [{:web3 web3
|
||||
:success-event success-event
|
||||
:src (accounts.db/current-public-key cofx)
|
||||
:src (accounts.model/current-public-key cofx)
|
||||
:chat chat-id
|
||||
:payload payload}]}))
|
||||
|
||||
|
@ -55,7 +55,7 @@
|
|||
{:keys [sym-key-id topic]} (get-in db [:transport/chats chat-id])]
|
||||
{:shh/post [{:web3 web3
|
||||
:success-event success-event
|
||||
:message (merge {:sig (accounts.db/current-public-key cofx)
|
||||
:message (merge {:sig (accounts.model/current-public-key cofx)
|
||||
:symKeyID sym-key-id
|
||||
:payload payload
|
||||
:topic (or topic
|
||||
|
@ -68,7 +68,7 @@
|
|||
(let [{:keys [web3]} db]
|
||||
{:shh/send-direct-message [{:web3 web3
|
||||
:success-event success-event
|
||||
:src (accounts.db/current-public-key cofx)
|
||||
:src (accounts.model/current-public-key cofx)
|
||||
:dst dst
|
||||
:topics (:mailserver/topics db)
|
||||
:payload payload}]}))
|
||||
|
@ -90,7 +90,7 @@
|
|||
(transport.topic/discovery-topic-hash))]
|
||||
{:shh/post [{:web3 web3
|
||||
:success-event success-event
|
||||
:message (merge {:sig (accounts.db/current-public-key cofx)
|
||||
:message (merge {:sig (accounts.model/current-public-key cofx)
|
||||
:pubKey chat-id
|
||||
:payload payload
|
||||
:topic topic-hash}
|
||||
|
@ -99,7 +99,7 @@
|
|||
(defrecord Message [content content-type message-type clock-value timestamp]
|
||||
StatusMessage
|
||||
(send [this chat-id {:keys [message-id] :as cofx}]
|
||||
(let [current-public-key (accounts.db/current-public-key cofx)
|
||||
(let [current-public-key (accounts.model/current-public-key cofx)
|
||||
params {:chat-id chat-id
|
||||
:payload this
|
||||
:success-event [:transport/message-sent
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
status-im.ui.screens.group.db
|
||||
status-im.chat.specs
|
||||
status-im.ui.screens.profile.db
|
||||
status-im.ui.screens.network-settings.db
|
||||
status-im.network.module
|
||||
status-im.mailserver.db
|
||||
status-im.browser.db
|
||||
status-im.ui.screens.add-new.db
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
[status-im.accounts.update.core :as accounts.update]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.ui.components.bottom-sheet.core :as bottom-sheet]
|
||||
[status-im.accounts.db :as accounts.db]
|
||||
[status-im.accounts.model :as accounts.model]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.mailserver.core :as mailserver]
|
||||
[status-im.ui.screens.mobile-network-settings.utils :as utils]))
|
||||
|
@ -16,7 +16,7 @@
|
|||
|
||||
(fx/defn on-network-status-change
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [logged-in? (accounts.db/logged-in? cofx)
|
||||
(let [logged-in? (accounts.model/logged-in? cofx)
|
||||
{:keys [remember-syncing-choice?]} (:account/account db)]
|
||||
(apply
|
||||
fx/merge
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
(ns status-im.ui.screens.profile.events
|
||||
(:require [re-frame.core :as re-frame]
|
||||
[status-im.browser.core :as browser]
|
||||
[status-im.accounts.db :as accounts.db]
|
||||
[status-im.accounts.model :as accounts.model]
|
||||
[status-im.ui.screens.profile.models :as profile.models]
|
||||
[status-im.ui.screens.profile.navigation]
|
||||
[status-im.ui.components.list-selection :as list-selection]
|
||||
|
@ -35,7 +35,7 @@
|
|||
(fn [{:keys [db] :as cofx}]
|
||||
{:db (-> db
|
||||
(assoc-in [:my-profile/profile :photo-path]
|
||||
(identicon/identicon (accounts.db/current-public-key cofx)))
|
||||
(identicon/identicon (accounts.model/current-public-key cofx)))
|
||||
(assoc :my-profile/editing? true))}))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
|
|
|
@ -40,13 +40,7 @@
|
|||
[status-im.ui.screens.mobile-network-settings.view
|
||||
:as
|
||||
mobile-network-settings]
|
||||
[status-im.ui.screens.network-settings.edit-network.views
|
||||
:as
|
||||
edit-network]
|
||||
[status-im.ui.screens.network-settings.network-details.views
|
||||
:as
|
||||
network-details]
|
||||
[status-im.ui.screens.network-settings.views :as network-settings]
|
||||
[status-im.network.module :as network]
|
||||
[status-im.ui.screens.offline-messaging-settings.edit-mailserver.views
|
||||
:as
|
||||
edit-mailserver]
|
||||
|
@ -151,9 +145,9 @@
|
|||
:extensions-settings screens.extensions/extensions-settings
|
||||
:edit-extension extensions.add/edit-extension
|
||||
:show-extension extensions.add/show-extension
|
||||
:network-settings network-settings/network-settings
|
||||
:network-details network-details/network-details
|
||||
:edit-network edit-network/edit-network
|
||||
:network-settings network/network-settings-view
|
||||
:network-details network/network-details-view
|
||||
:edit-network network/edit-network-view
|
||||
:log-level-settings log-level-settings/log-level-settings
|
||||
:fleet-settings fleet-settings/fleet-settings
|
||||
:currency-settings currency-settings/currency-settings
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
(ns status-im.utils.handlers
|
||||
(:require [cljs.spec.alpha :as spec]
|
||||
[clojure.string :as string]
|
||||
[re-frame.core :as re-frame]
|
||||
[re-frame.interceptor :refer [->interceptor get-coeffect get-effect]]
|
||||
[status-im.accounts.db :as accounts.db]
|
||||
[cljs.core.async :as async]
|
||||
[status-im.accounts.model :as accounts.model]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(def pre-event-callback (atom nil))
|
||||
|
@ -40,7 +38,7 @@
|
|||
:id :logged-in
|
||||
:before (fn logged-in-before
|
||||
[context]
|
||||
(when (accounts.db/logged-in? (:coeffects context))
|
||||
(when (accounts.model/logged-in? (:coeffects context))
|
||||
context))))
|
||||
|
||||
(defn- check-spec-msg-path-problem [problem]
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
(:require [cljs.spec.alpha :as spec]
|
||||
[goog.string :as gstring]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.accounts.db :as accounts.db]
|
||||
[status-im.accounts.model :as accounts.model]
|
||||
[status-im.chat.models :as chat]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.ethereum.eip681 :as eip681]
|
||||
|
@ -131,7 +131,7 @@
|
|||
"Store url in the database if the user is not logged in, to be processed
|
||||
on login, otherwise just handle it"
|
||||
[cofx url]
|
||||
(if (accounts.db/logged-in? cofx)
|
||||
(if (accounts.model/logged-in? cofx)
|
||||
(route-url cofx url)
|
||||
(store-url-for-later cofx url)))
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
(ns status-im.test.models.account
|
||||
(:require [cljs.test :refer-macros [deftest is testing]]
|
||||
[status-im.accounts.db :as accounts.db]))
|
||||
[status-im.accounts.model :as accounts.db]))
|
||||
|
||||
(deftest logged-in-test
|
||||
(testing "account/account is defined"
|
||||
|
|
Loading…
Reference in New Issue