Add toggle in advanced settings for mobile data
4a43b2b2...9755b3de
Co-authored-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
parent
55c620e59d
commit
4586f8007c
1
.env.e2e
1
.env.e2e
|
@ -38,3 +38,4 @@ SHOW_NOT_IMPLEMENTED_FEATURES=1
|
|||
DELETE_MESSAGE_FOR_ME_UNDO_TIME_LIMIT=10000
|
||||
DELETE_MESSAGE_UNDO_TIME_LIMIT=10000
|
||||
ENABLE_ALERT_BANNER=0
|
||||
MOBILE_DATA_SYNCING_TOGGLE_ENABLE=0
|
||||
|
|
|
@ -11,9 +11,6 @@
|
|||
legacy.status-im.fleet.core
|
||||
legacy.status-im.group-chats.core
|
||||
legacy.status-im.log-level.core
|
||||
legacy.status-im.mailserver.constants
|
||||
[legacy.status-im.mailserver.core :as mailserver]
|
||||
legacy.status-im.mobile-sync-settings.core
|
||||
legacy.status-im.multiaccounts.login.core
|
||||
legacy.status-im.multiaccounts.logout.core
|
||||
[legacy.status-im.multiaccounts.model :as multiaccounts.model]
|
||||
|
@ -134,7 +131,6 @@
|
|||
(rf/merge cofx
|
||||
{:db (dissoc db :app-in-background-since)
|
||||
:effects.biometric/get-supported-type nil}
|
||||
(mailserver/process-next-messages-request)
|
||||
(when-not new-account?
|
||||
(universal-links/process-stored-event))
|
||||
#(when-let [chat-id (:current-chat-id db)]
|
||||
|
|
|
@ -1,437 +0,0 @@
|
|||
(ns ^{:doc "Mailserver events and API"} legacy.status-im.mailserver.core
|
||||
(:require
|
||||
[clojure.string :as string]
|
||||
[legacy.status-im.multiaccounts.update.core :as multiaccounts.update]
|
||||
[legacy.status-im.node.core :as node]
|
||||
[legacy.status-im.utils.mobile-sync :as mobile-network-utils]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.common.json-rpc.events :as json-rpc]
|
||||
[status-im.navigation.events :as navigation]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
;; How do mailserver work ?
|
||||
;;
|
||||
;; - We send a request to the mailserver, we are only interested in the
|
||||
;; messages since `last-request` up to the last seven days
|
||||
;; and the last 24 hours for topics that were just joined
|
||||
;; - The mailserver doesn't directly respond to the request and
|
||||
;; instead we start receiving messages in the filters for the requested
|
||||
;; topics.
|
||||
;; - If the mailserver was not ready when we tried for instance to request
|
||||
;; the history of a topic after joining a chat, the request will be done
|
||||
;; as soon as the mailserver becomes available
|
||||
|
||||
|
||||
(defn connected?
|
||||
[db id]
|
||||
(= (:mailserver/current-id db) id))
|
||||
|
||||
(defn fetch
|
||||
[db id]
|
||||
(get-in db [:mailserver/mailservers (node/current-fleet-key db) id]))
|
||||
|
||||
(defn fetch-current
|
||||
[db]
|
||||
(fetch db (:mailserver/current-id db)))
|
||||
|
||||
(defn preferred-mailserver-id
|
||||
[db]
|
||||
(get-in db [:profile/profile :pinned-mailservers (node/current-fleet-key db)]))
|
||||
|
||||
(defn connection-error-dismissed
|
||||
[db]
|
||||
(get-in db [:mailserver/connection-error-dismissed]))
|
||||
|
||||
(defn mailserver-address->id
|
||||
[db address]
|
||||
(let [current-fleet (node/current-fleet-key db)]
|
||||
(:id (some #(when (= address (:address %))
|
||||
%)
|
||||
(-> db
|
||||
:mailserver/mailservers
|
||||
current-fleet
|
||||
vals)))))
|
||||
|
||||
(rf/defn disconnect-from-mailserver
|
||||
{:events [::disconnect-from-mailserver]}
|
||||
[{:keys [db] :as cofx}]
|
||||
{:db (-> db
|
||||
(assoc :mailserver/state nil)
|
||||
(dissoc :mailserver/current-request :mailserver/fetching-gaps-in-progress))})
|
||||
|
||||
(defn fetch-use-mailservers?
|
||||
[db]
|
||||
(get-in db [:profile/profile :use-mailservers?]))
|
||||
|
||||
(defonce showing-connection-error-popup? (atom false))
|
||||
|
||||
(defn cancel-connection-popup!
|
||||
[]
|
||||
(reset! showing-connection-error-popup? false)
|
||||
(re-frame/dispatch [:mailserver.ui/dismiss-connection-error true]))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::cancel-connection-popup
|
||||
cancel-connection-popup!)
|
||||
|
||||
(rf/defn show-connection-error!
|
||||
[cofx current-fleet preferred-mailserver]
|
||||
(reset! showing-connection-error-popup? true)
|
||||
{:ui/show-confirmation
|
||||
{:title (i18n/label :t/mailserver-error-title)
|
||||
:content (i18n/label :t/mailserver-error-content)
|
||||
:confirm-button-text (i18n/label :t/mailserver-pick-another)
|
||||
:on-cancel cancel-connection-popup!
|
||||
:on-accept #(do
|
||||
(reset! showing-connection-error-popup? false)
|
||||
(re-frame/dispatch [:mailserver.ui/dismiss-connection-error true])
|
||||
(re-frame/dispatch [:navigate-to :offline-messaging-settings]))
|
||||
:extra-options [{:text (i18n/label :t/mailserver-retry)
|
||||
:onPress #(do
|
||||
(reset! showing-connection-error-popup? false)
|
||||
(re-frame/dispatch
|
||||
[:mailserver.ui/connect-confirmed
|
||||
current-fleet
|
||||
preferred-mailserver]))
|
||||
:style "default"}]}})
|
||||
|
||||
(rf/defn handle-successful-request
|
||||
{:events [::request-success]}
|
||||
[{:keys [db] :as cofx} response-js]
|
||||
{:db (dissoc db :mailserver/current-request)
|
||||
:dispatch [:sanitize-messages-and-process-response response-js]})
|
||||
|
||||
(rf/defn handle-mailserver-not-working
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [current-fleet (node/current-fleet-key db)
|
||||
error-dismissed? (connection-error-dismissed db)
|
||||
pinned-mailserver (get-in db [:profile/profile :pinned-mailservers current-fleet])]
|
||||
(when (and pinned-mailserver
|
||||
(not error-dismissed?)
|
||||
(not @showing-connection-error-popup?))
|
||||
(show-connection-error! cofx current-fleet pinned-mailserver))))
|
||||
|
||||
(rf/defn handle-request-error
|
||||
{:events [::request-error]}
|
||||
[{:keys [db] :as cofx}]
|
||||
{:db (dissoc db :mailserver/current-request)})
|
||||
|
||||
(defn needs-to-fetch-historic-messages?
|
||||
[db]
|
||||
(and
|
||||
(:messenger/started? db)
|
||||
(mobile-network-utils/syncing-allowed? db)
|
||||
(fetch-use-mailservers? db)
|
||||
(not (:mailserver/current-request db))))
|
||||
|
||||
(rf/defn process-next-messages-request
|
||||
{:events [::request-messages]}
|
||||
[{:keys [db]}]
|
||||
(when (needs-to-fetch-historic-messages? db)
|
||||
{:db (assoc db :mailserver/current-request true)
|
||||
:mailserver/request-all-historic-messages nil}))
|
||||
|
||||
(re-frame/reg-fx :mailserver/request-all-historic-messages
|
||||
(fn []
|
||||
(json-rpc/call {:method "wakuext_requestAllHistoricMessagesWithRetries"
|
||||
:params [false]
|
||||
:js-response true
|
||||
:on-success #(do
|
||||
(log/info "fetched historical messages")
|
||||
(re-frame/dispatch [::request-success %]))
|
||||
:on-error #(do
|
||||
(log/error "failed retrieve historical messages" %)
|
||||
(re-frame/dispatch [::request-error]))})))
|
||||
|
||||
(rf/defn handle-mailserver-changed
|
||||
[{:keys [db] :as cofx} ms]
|
||||
(if (seq ms)
|
||||
{:db (assoc db
|
||||
:mailserver/state :connecting
|
||||
:mailserver/current-id (keyword ms))}
|
||||
{:db (assoc db :mailserver/state nil)}))
|
||||
|
||||
(rf/defn handle-mailserver-available
|
||||
[{:keys [db] :as cofx} ms]
|
||||
{::cancel-connection-popup []
|
||||
:db (assoc db
|
||||
:mailserver/state :connected
|
||||
:mailserver/current-id (keyword ms))})
|
||||
|
||||
(rf/defn connected-to-mailserver
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [{:keys [address]} (fetch-current db)]
|
||||
(rf/merge
|
||||
cofx
|
||||
{:mailserver/update-mailservers [[address] #(re-frame/dispatch [::request-messages])]})))
|
||||
|
||||
(rf/defn handle-request-success
|
||||
{:events [:mailserver.callback/request-success]}
|
||||
[{{:keys [chats] :as db} :db} {:keys [request-id topics]}]
|
||||
(when (:mailserver/current-request db)
|
||||
{:db (assoc-in db
|
||||
[:mailserver/current-request :request-id]
|
||||
request-id)}))
|
||||
|
||||
(rf/defn toggle-use-mailservers
|
||||
[cofx value]
|
||||
{:json-rpc/call
|
||||
[{:method "wakuext_toggleUseMailservers"
|
||||
:params [value]
|
||||
:on-success #(log/info "successfully toggled use-mailservers" value)
|
||||
:on-failure #(log/error "failed to toggle use-mailserver" value %)}]})
|
||||
|
||||
(rf/defn update-use-mailservers
|
||||
{:events [:mailserver.ui/use-history-switch-pressed]}
|
||||
[cofx use-mailservers?]
|
||||
(rf/merge cofx
|
||||
(multiaccounts.update/optimistic :use-mailservers? use-mailservers?)
|
||||
(toggle-use-mailservers use-mailservers?)
|
||||
(when use-mailservers?
|
||||
(disconnect-from-mailserver))))
|
||||
|
||||
(rf/defn retry-next-messages-request
|
||||
{:events [:mailserver.ui/retry-request-pressed]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(rf/merge cofx
|
||||
{:db (dissoc db :mailserver/request-error)}
|
||||
(process-next-messages-request)))
|
||||
|
||||
(rf/defn show-request-error-popup
|
||||
{:events [:mailserver.ui/request-error-pressed]}
|
||||
[{:keys [db]}]
|
||||
(let [mailserver-error (:mailserver/request-error db)]
|
||||
{:effects.utils/show-confirmation
|
||||
{:title (i18n/label :t/mailserver-request-error-title)
|
||||
:content (i18n/label :t/mailserver-request-error-content
|
||||
{:error mailserver-error})
|
||||
:on-accept #(re-frame/dispatch [:mailserver.ui/retry-request-pressed])
|
||||
:confirm-button-text (i18n/label :t/mailserver-request-retry)}}))
|
||||
|
||||
(def enode-url-regex
|
||||
#"enode://[a-zA-Z0-9]+\@\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b:(\d{1,5})")
|
||||
|
||||
(defn- extract-url-components
|
||||
[address]
|
||||
(rest (re-matches #"enode://(.*)@(.*)" address)))
|
||||
|
||||
(defn valid-enode-url?
|
||||
[address]
|
||||
(re-matches enode-url-regex address))
|
||||
|
||||
(defn build-url
|
||||
[address]
|
||||
(let [[initial host] (extract-url-components address)]
|
||||
(str "enode://" initial "@" host)))
|
||||
|
||||
(rf/defn set-input
|
||||
{:events [:mailserver.ui/input-changed]}
|
||||
[{:keys [db]} input-key value]
|
||||
{:db (update
|
||||
db
|
||||
:mailserver.edit/mailserver
|
||||
assoc
|
||||
input-key
|
||||
{:value value
|
||||
:error (case input-key
|
||||
:id false
|
||||
:name (string/blank? value)
|
||||
:url (not (valid-enode-url? value)))})})
|
||||
|
||||
(defn- address->mailserver
|
||||
[address]
|
||||
(let [[enode url :as response] (extract-url-components address)]
|
||||
{:address (if (seq response)
|
||||
(str "enode://" enode "@" url)
|
||||
address)
|
||||
:custom true}))
|
||||
|
||||
(defn- build
|
||||
[id mailserver-name address]
|
||||
(assoc (address->mailserver address)
|
||||
:id id
|
||||
:name mailserver-name))
|
||||
|
||||
(def default? (comp not :custom fetch))
|
||||
|
||||
(rf/defn edit
|
||||
{:events [:mailserver.ui/custom-mailserver-selected]}
|
||||
[{:keys [db] :as cofx} id]
|
||||
(let [{:keys [id address name]} (fetch db id)
|
||||
url (when address (build-url address))]
|
||||
(rf/merge cofx
|
||||
(set-input :id id)
|
||||
(set-input :url (str url))
|
||||
(set-input :name (str name))
|
||||
(navigation/navigate-to :edit-mailserver nil))))
|
||||
|
||||
(defn mailserver->rpc
|
||||
[mailserver current-fleet]
|
||||
(-> mailserver
|
||||
(assoc :fleet (name current-fleet))
|
||||
(update :id name)))
|
||||
|
||||
(rf/defn upsert
|
||||
{:events [:mailserver.ui/save-pressed]
|
||||
:interceptors [(re-frame/inject-cofx :random-id-generator)]}
|
||||
[{{:mailserver.edit/keys [mailserver] :profile/keys [profile] :as db} :db
|
||||
random-id-generator :random-id-generator
|
||||
:as cofx}]
|
||||
|
||||
(let [{:keys [name url id]} mailserver
|
||||
current-fleet (node/current-fleet-key db)]
|
||||
(when (and (not (string/blank? (:value name)))
|
||||
(valid-enode-url? (:value url)))
|
||||
|
||||
(let [mailserver (build
|
||||
(or (:value id)
|
||||
(keyword (string/replace (random-id-generator) "-" "")))
|
||||
(:value name)
|
||||
(:value url))
|
||||
current (connected? db (:id mailserver))]
|
||||
{:db (-> db
|
||||
(dissoc :mailserver.edit/mailserver)
|
||||
(assoc-in [:mailserver/mailservers current-fleet (:id mailserver)]
|
||||
mailserver))
|
||||
:json-rpc/call
|
||||
[{:method "mailservers_addMailserver"
|
||||
:params [(mailserver->rpc mailserver current-fleet)]
|
||||
:on-success (fn []
|
||||
;; we naively logout if the user is connected to the edited mailserver
|
||||
(when current
|
||||
(re-frame/dispatch
|
||||
[:multiaccounts.logout.ui/logout-confirmed]))
|
||||
(log/debug "saved mailserver" id "successfuly"))
|
||||
:on-failure #(log/error "failed to save mailserver" id %)}]
|
||||
:dispatch [:navigate-back]}))))
|
||||
|
||||
(defn can-delete?
|
||||
[db id]
|
||||
(not (or (default? db id)
|
||||
(connected? db id))))
|
||||
|
||||
(rf/defn delete
|
||||
{:events [:mailserver.ui/delete-confirmed]}
|
||||
[{:keys [db] :as cofx} id]
|
||||
(if (can-delete? db id)
|
||||
{:db (-> db
|
||||
(update-in
|
||||
[:mailserver/mailservers (node/current-fleet-key db)]
|
||||
dissoc
|
||||
id)
|
||||
(dissoc :mailserver.edit/mailserver))
|
||||
:json-rpc/call
|
||||
[{:method "mailservers_deleteMailserver"
|
||||
:params [(name id)]
|
||||
:on-success #(log/debug "deleted mailserver" id)
|
||||
:on-failure #(log/error "failed to delete mailserver" id %)}]
|
||||
:dispatch [:navigate-back]}
|
||||
{:dispatch [:navigate-back]}))
|
||||
|
||||
(rf/defn show-connection-confirmation
|
||||
{:events [:mailserver.ui/default-mailserver-selected :mailserver.ui/connect-pressed]}
|
||||
[{:keys [db]} mailserver-id]
|
||||
(let [current-fleet (node/current-fleet-key db)]
|
||||
{:ui/show-confirmation
|
||||
{:title (i18n/label :t/close-app-title)
|
||||
:content
|
||||
(i18n/label :t/connect-mailserver-content
|
||||
{:name (get-in db
|
||||
[:mailserver/mailservers
|
||||
current-fleet mailserver-id :name])})
|
||||
:confirm-button-text (i18n/label :t/close-app-button)
|
||||
:on-accept
|
||||
#(re-frame/dispatch
|
||||
[:mailserver.ui/connect-confirmed current-fleet mailserver-id])
|
||||
:on-cancel nil}}))
|
||||
|
||||
(rf/defn show-delete-confirmation
|
||||
{:events [:mailserver.ui/delete-pressed]}
|
||||
[{:keys [db]} mailserver-id]
|
||||
{:ui/show-confirmation
|
||||
{:title (i18n/label :t/delete-mailserver-title)
|
||||
:content (i18n/label :t/delete-mailserver-are-you-sure)
|
||||
:confirm-button-text (i18n/label :t/delete-mailserver)
|
||||
:on-accept #(re-frame/dispatch
|
||||
[:mailserver.ui/delete-confirmed mailserver-id])}})
|
||||
|
||||
(rf/defn set-url-from-qr
|
||||
{:events [:mailserver.callback/qr-code-scanned]}
|
||||
[cofx url]
|
||||
(assoc (set-input cofx :url url)
|
||||
:dispatch
|
||||
[:navigate-back]))
|
||||
|
||||
(rf/defn dismiss-connection-error
|
||||
{:events [:mailserver.ui/dismiss-connection-error]}
|
||||
[{:keys [db]} new-state]
|
||||
{:db (assoc db :mailserver/connection-error-dismissed new-state)})
|
||||
|
||||
(rf/defn pin-mailserver
|
||||
{:events [:mailserver.ui/connect-confirmed]}
|
||||
[{:keys [db] :as cofx} current-fleet mailserver-id]
|
||||
(let [pinned-mailservers (-> db
|
||||
(get-in [:profile/profile :pinned-mailservers])
|
||||
(assoc current-fleet mailserver-id))]
|
||||
(rf/merge cofx
|
||||
{:db (assoc db :mailserver/current-id mailserver-id)
|
||||
:json-rpc/call [{:method "wakuext_setPinnedMailservers"
|
||||
:params [pinned-mailservers]
|
||||
:on-success #(log/info "successfully pinned mailserver")
|
||||
:on-error #(log/error "failed to pin mailserver" %)}]}
|
||||
(multiaccounts.update/optimistic :pinned-mailservers pinned-mailservers))))
|
||||
|
||||
(rf/defn unpin
|
||||
{:events [:mailserver.ui/unpin-pressed]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [current-fleet (node/current-fleet-key db)
|
||||
pinned-mailservers (-> db
|
||||
(get-in [:profile/profile :pinned-mailservers])
|
||||
(dissoc current-fleet))]
|
||||
(rf/merge cofx
|
||||
{:json-rpc/call [{:method "wakuext_setPinnedMailservers"
|
||||
:params [pinned-mailservers]
|
||||
:on-success #(log/info "successfully unpinned mailserver")
|
||||
:on-error #(log/error "failed to unpin mailserver" %)}]}
|
||||
(multiaccounts.update/optimistic
|
||||
:pinned-mailservers
|
||||
pinned-mailservers)
|
||||
(dismiss-connection-error false))))
|
||||
|
||||
(rf/defn pin
|
||||
{:events [:mailserver.ui/pin-pressed]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [current-fleet (node/current-fleet-key db)
|
||||
mailserver-id (:mailserver/current-id db)
|
||||
pinned-mailservers (get-in db [:profile/profile :pinned-mailservers])]
|
||||
(rf/merge cofx
|
||||
(multiaccounts.update/multiaccount-update
|
||||
:pinned-mailservers
|
||||
(assoc pinned-mailservers
|
||||
current-fleet
|
||||
mailserver-id)
|
||||
{})
|
||||
(dismiss-connection-error false))))
|
||||
|
||||
(rf/defn mailserver-ui-add-pressed
|
||||
{:events [:mailserver.ui/add-pressed]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(rf/merge cofx
|
||||
{:db (dissoc db :mailserver.edit/mailserver)}
|
||||
(navigation/navigate-to :edit-mailserver nil)))
|
||||
|
||||
(defn add-mailservers
|
||||
[db mailservers]
|
||||
(reduce (fn [db {:keys [fleet id name] :as mailserver}]
|
||||
(let [updated-mailserver
|
||||
(-> mailserver
|
||||
(update :id keyword)
|
||||
(assoc :name (if (seq name) name id))
|
||||
(dissoc :fleet))]
|
||||
(assoc-in db
|
||||
[:mailserver/mailservers (keyword fleet) (keyword id)]
|
||||
updated-mailserver)))
|
||||
db
|
||||
mailservers))
|
|
@ -1,109 +0,0 @@
|
|||
(ns legacy.status-im.mobile-sync-settings.core
|
||||
(:require
|
||||
[legacy.status-im.mailserver.core :as mailserver]
|
||||
[legacy.status-im.multiaccounts.model :as multiaccounts.model]
|
||||
[legacy.status-im.multiaccounts.update.core :as multiaccounts.update]
|
||||
[legacy.status-im.utils.mobile-sync :as utils]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.navigation.events :as navigation]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(rf/defn sheet-defaults
|
||||
[{:keys [db]}]
|
||||
(let [remember-choice? (get-in db [:profile/profile :remember-syncing-choice?])]
|
||||
{:db (assoc db
|
||||
:mobile-network/remember-choice?
|
||||
(or (nil? remember-choice?)
|
||||
remember-choice?))}))
|
||||
|
||||
(re-frame/reg-event-fx :mobile-network/on-network-status-change
|
||||
(fn [{:keys [db]}]
|
||||
(let [previously-initialized? (get db :network-status/initialized?)
|
||||
logged-in? (multiaccounts.model/logged-in? db)
|
||||
fetch-historic-messages? (mailserver/needs-to-fetch-historic-messages? db)]
|
||||
(if logged-in?
|
||||
{:db (cond-> (-> db
|
||||
(assoc :network-status/initialized? true)
|
||||
(assoc :bottom-sheet/show? false))
|
||||
fetch-historic-messages?
|
||||
(assoc :mailserver/current-request true))
|
||||
:fx [(when fetch-historic-messages?
|
||||
[:mailserver/request-all-historic-messages])
|
||||
[:dispatch [:hide-bottom-sheet]]
|
||||
(when previously-initialized?
|
||||
(let [new-identity-input (get-in db [:contacts/new-identity :input])]
|
||||
[:dispatch [:contacts/set-new-identity {:input new-identity-input}]]))]}
|
||||
{:db (assoc db :network-status/initialized? true)}))))
|
||||
|
||||
(defn apply-settings
|
||||
([sync?] (apply-settings sync? :default))
|
||||
([sync? remember?]
|
||||
(fn [{:keys [db] :as cofx}]
|
||||
(let [network (:network/type db)
|
||||
remember-choice?
|
||||
(if (not= :default remember?)
|
||||
remember?
|
||||
(:mobile-network/remember-choice? db))
|
||||
cellular? (utils/cellular? network)]
|
||||
(log/info "apply mobile network settings"
|
||||
"sunc?" sync?
|
||||
"remember?" remember?
|
||||
"cellular?" cellular?)
|
||||
(rf/merge
|
||||
cofx
|
||||
(multiaccounts.update/multiaccount-update
|
||||
:syncing-on-mobile-network?
|
||||
(boolean sync?)
|
||||
{})
|
||||
(multiaccounts.update/multiaccount-update
|
||||
:remember-syncing-choice?
|
||||
(boolean remember-choice?)
|
||||
{})
|
||||
(when (and cellular? sync?)
|
||||
(mailserver/process-next-messages-request)))))))
|
||||
|
||||
(rf/defn mobile-network-continue-syncing
|
||||
{:events [:mobile-network/continue-syncing]}
|
||||
[cofx]
|
||||
((apply-settings true) cofx))
|
||||
|
||||
(rf/defn mobile-network-stop-syncing
|
||||
{:events [:mobile-network/stop-syncing]}
|
||||
[cofx]
|
||||
((apply-settings false) cofx))
|
||||
|
||||
(rf/defn mobile-network-set-syncing
|
||||
{:events [:mobile-network/set-syncing]}
|
||||
[{:keys [db] :as cofx} syncing?]
|
||||
(let [{:keys [remember-syncing-choice?]} (:profile/profile db)]
|
||||
((apply-settings syncing? remember-syncing-choice?) cofx)))
|
||||
|
||||
(rf/defn mobile-network-ask-on-mobile-network?
|
||||
{:events [:mobile-network/ask-on-mobile-network?]}
|
||||
[{:keys [db] :as cofx} ask?]
|
||||
(let [{:keys [syncing-on-mobile-network?]} (:profile/profile db)]
|
||||
((apply-settings syncing-on-mobile-network? (not ask?)) cofx)))
|
||||
|
||||
(rf/defn mobile-network-restore-defaults
|
||||
{:events [:mobile-network/restore-defaults]}
|
||||
[cofx]
|
||||
((apply-settings false false) cofx))
|
||||
|
||||
(rf/defn mobile-network-remember-choice?
|
||||
{:events [:mobile-network/remember-choice?]}
|
||||
[{:keys [db]} remember-choice?]
|
||||
{:db (assoc db :mobile-network/remember-choice? remember-choice?)})
|
||||
|
||||
(rf/defn mobile-network-navigate-to-settings
|
||||
{:events [:mobile-network/navigate-to-settings]}
|
||||
[cofx]
|
||||
(rf/merge
|
||||
cofx
|
||||
(navigation/hide-bottom-sheet)
|
||||
(navigation/navigate-to :mobile-network-settings nil)))
|
||||
|
||||
(rf/defn mobile-network-show-offline-sheet
|
||||
{:events [:mobile-network/show-offline-sheet]}
|
||||
[cofx]
|
||||
(navigation/hide-bottom-sheet cofx))
|
|
@ -14,12 +14,13 @@
|
|||
|
||||
(rf/defn initialize-app-db
|
||||
[{{:keys [keycard initials-avatar-font-file biometrics]
|
||||
:network/keys [type status]
|
||||
:network/keys [type status expensive?]
|
||||
:wallet-connect/keys [web3-wallet]}
|
||||
:db}]
|
||||
{:db (assoc db/app-db
|
||||
:network/type type
|
||||
:network/status status
|
||||
:network/expensive? expensive?
|
||||
:initials-avatar-font-file initials-avatar-font-file
|
||||
:keycard (dissoc keycard :secrets :pin :application-info)
|
||||
:biometrics biometrics
|
||||
|
|
|
@ -1,51 +0,0 @@
|
|||
(ns legacy.status-im.ui.screens.mobile-network-settings.sheets
|
||||
(:require-macros [legacy.status-im.utils.views :as views])
|
||||
(:require [legacy.status-im.ui.components.list.item :as list.item]
|
||||
[legacy.status-im.ui.components.react :as react]
|
||||
[legacy.status-im.ui.screens.mobile-network-settings.sheets-styles :as styles]
|
||||
[re-frame.core :as re-frame]
|
||||
[utils.i18n :as i18n]))
|
||||
|
||||
(defn title
|
||||
[label]
|
||||
[react/view {:style styles/title}
|
||||
[react/text
|
||||
{:style styles/title-text}
|
||||
(i18n/label label)]])
|
||||
|
||||
(defn details
|
||||
[label]
|
||||
[react/view
|
||||
{:style styles/details}
|
||||
[react/text
|
||||
{:style styles/details-text}
|
||||
(i18n/label label)]])
|
||||
|
||||
(defn separator
|
||||
[]
|
||||
[react/view {:style styles/separator}])
|
||||
|
||||
(defn go-to-settings
|
||||
[]
|
||||
[react/view
|
||||
{:style styles/go-to-settings-container}
|
||||
[react/text
|
||||
{:style styles/go-to-settings
|
||||
:on-press #(re-frame/dispatch [:mobile-network/navigate-to-settings])}
|
||||
(i18n/label :t/mobile-network-go-to-settings)]])
|
||||
|
||||
(views/defview offline-sheet
|
||||
[]
|
||||
[react/view {:flex 1}
|
||||
[react/view {:align-items :center}
|
||||
[title :t/mobile-network-sheet-offline]
|
||||
[details :t/mobile-network-sheet-offline-details]]
|
||||
[list.item/list-item
|
||||
{:theme :accent
|
||||
:title (i18n/label :t/mobile-network-start-syncing)
|
||||
:subtitle (i18n/label :t/mobile-network-continue-syncing-details)
|
||||
:subtitle-max-lines 2
|
||||
:icon :main-icons/network
|
||||
:on-press #(re-frame/dispatch [:mobile-network/continue-syncing])}]
|
||||
[separator]
|
||||
[go-to-settings]])
|
|
@ -1,73 +0,0 @@
|
|||
(ns legacy.status-im.ui.screens.mobile-network-settings.sheets-styles
|
||||
(:require
|
||||
[legacy.status-im.ui.components.colors :as colors]))
|
||||
|
||||
(def title
|
||||
{:height 21
|
||||
:margin-top 8})
|
||||
|
||||
(def title-text
|
||||
{:typography :title-bold})
|
||||
|
||||
(def details
|
||||
{:width 311
|
||||
:margin-left 32
|
||||
:margin-right 32
|
||||
:margin-top 6
|
||||
:margin-bottom 10})
|
||||
|
||||
(def details-text
|
||||
{:color colors/gray
|
||||
:text-align :center})
|
||||
|
||||
(def separator
|
||||
{:background-color colors/gray-lighter
|
||||
:margin-left 72
|
||||
:align-self :stretch
|
||||
:height 1
|
||||
:margin-top 8})
|
||||
|
||||
(def checkbox-line-container
|
||||
{:margin-left 71
|
||||
:margin-top 13
|
||||
:height 29
|
||||
:flex-direction :row
|
||||
:justify-content :center})
|
||||
|
||||
(def checkbox
|
||||
{:padding 0
|
||||
:justify-content :center
|
||||
:align-items :center
|
||||
:width 18
|
||||
:height 18
|
||||
:border-radius 2
|
||||
:margin-top 6})
|
||||
|
||||
(def checkbox-icon
|
||||
{:tint-color colors/white})
|
||||
|
||||
(def checkbox-text-container
|
||||
{:justify-content :center
|
||||
:flex 1
|
||||
:margin-left 13})
|
||||
|
||||
(def settings-container
|
||||
{:margin-left 69
|
||||
:height 44
|
||||
:margin-top 6
|
||||
:align-items :flex-start})
|
||||
|
||||
(def settings-text
|
||||
{:color colors/gray})
|
||||
|
||||
(def settings-link
|
||||
{:color colors/blue})
|
||||
|
||||
(def go-to-settings-container
|
||||
{:height 52
|
||||
:margin-left 72
|
||||
:justify-content :center
|
||||
:align-self :stretch})
|
||||
|
||||
(def go-to-settings
|
||||
{:color colors/blue})
|
|
@ -1,32 +0,0 @@
|
|||
(ns legacy.status-im.ui.screens.mobile-network-settings.style
|
||||
(:require
|
||||
[legacy.status-im.ui.components.colors :as colors]))
|
||||
|
||||
(def container
|
||||
{:flex 1})
|
||||
|
||||
(def switch-container
|
||||
{:height 52})
|
||||
|
||||
(def details
|
||||
{:margin-right 16
|
||||
:margin-left 16
|
||||
:margin-top 8
|
||||
:margin-bottom 16})
|
||||
|
||||
(def use-mobile-data-text
|
||||
{:color colors/gray})
|
||||
|
||||
(defn settings-separator
|
||||
[]
|
||||
{:align-self :stretch
|
||||
:height 1
|
||||
:background-color colors/gray-lighter})
|
||||
|
||||
(def defaults-container
|
||||
{:height 52
|
||||
:justify-content :center
|
||||
:padding-left 16})
|
||||
|
||||
(def defaults
|
||||
{:color colors/blue})
|
|
@ -1,57 +0,0 @@
|
|||
(ns legacy.status-im.ui.screens.mobile-network-settings.view
|
||||
(:require-macros [legacy.status-im.utils.views :as views])
|
||||
(:require
|
||||
legacy.status-im.mobile-sync-settings.core
|
||||
[legacy.status-im.ui.components.react :as react]
|
||||
[legacy.status-im.ui.screens.mobile-network-settings.sheets :as sheets]
|
||||
[legacy.status-im.ui.screens.mobile-network-settings.style :as styles]
|
||||
[legacy.status-im.ui.screens.profile.components.views :as profile.components]
|
||||
[re-frame.core :as re-frame]
|
||||
[utils.i18n :as i18n]))
|
||||
|
||||
(defn hide-sheet-and-dispatch
|
||||
[event]
|
||||
(re-frame/dispatch [:bottom-sheet/hide-old])
|
||||
(re-frame/dispatch event))
|
||||
|
||||
(defn settings-separator
|
||||
[]
|
||||
[react/view
|
||||
{:style (styles/settings-separator)}])
|
||||
|
||||
;; TODO(Ferossgp): To refactor, uses outdated components
|
||||
(views/defview mobile-network-settings
|
||||
[]
|
||||
(views/letsubs
|
||||
[{:keys [syncing-on-mobile-network?
|
||||
remember-syncing-choice?]}
|
||||
[:profile/profile]]
|
||||
[:<>
|
||||
[react/view
|
||||
{:style styles/switch-container
|
||||
:accessibility-label "mobile-network-use-mobile"}
|
||||
[profile.components/settings-switch-item
|
||||
{:label-kw :t/mobile-network-use-mobile
|
||||
:value syncing-on-mobile-network?
|
||||
:action-fn #(hide-sheet-and-dispatch [:mobile-network/set-syncing %])}]]
|
||||
[react/view {:style styles/details}
|
||||
[react/text {:style styles/use-mobile-data-text}
|
||||
(i18n/label :t/mobile-network-use-mobile-data)]]
|
||||
[react/view
|
||||
{:style styles/switch-container
|
||||
:accessibility-label "mobile-network-ask-me"}
|
||||
[profile.components/settings-switch-item
|
||||
{:label-kw :t/mobile-network-ask-me
|
||||
:value (not remember-syncing-choice?)
|
||||
:action-fn #(hide-sheet-and-dispatch [:mobile-network/ask-on-mobile-network? %])}]]
|
||||
[settings-separator]
|
||||
[react/view
|
||||
{:style styles/defaults-container}
|
||||
[react/text
|
||||
{:style styles/defaults
|
||||
:accessibility-label "restore-defaults"
|
||||
:on-press #(hide-sheet-and-dispatch [:mobile-network/restore-defaults])}
|
||||
(i18n/label :t/restore-defaults)]]]))
|
||||
|
||||
(def offline-sheet
|
||||
{:content sheets/offline-sheet})
|
|
@ -13,7 +13,6 @@
|
|||
[legacy.status-im.ui.screens.glossary.view :as glossary]
|
||||
[legacy.status-im.ui.screens.help-center.views :as help-center]
|
||||
[legacy.status-im.ui.screens.log-level-settings.views :as log-level-settings]
|
||||
[legacy.status-im.ui.screens.mobile-network-settings.view :as mobile-network-settings]
|
||||
[legacy.status-im.ui.screens.notifications-settings.views :as notifications-settings]
|
||||
[legacy.status-im.ui.screens.offline-messaging-settings.edit-mailserver.views :as edit-mailserver]
|
||||
[legacy.status-im.ui.screens.offline-messaging-settings.views :as offline-messaging-settings]
|
||||
|
@ -145,10 +144,6 @@
|
|||
:options {:topBar (topbar-options :t/fleet-settings)
|
||||
:insets {:top? true}}
|
||||
:component fleet-settings/fleet-settings}
|
||||
{:name :mobile-network-settings
|
||||
:options {:topBar (topbar-options :t/mobile-network-settings)
|
||||
:insets {:top? true}}
|
||||
:component mobile-network-settings/mobile-network-settings}
|
||||
{:name :backup-settings
|
||||
:options {:topBar (topbar-options :t/backup-settings)
|
||||
:insets {:top? true}}
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
|
||||
(defn icon-color
|
||||
[{:keys [theme blur? type]}]
|
||||
(let [theme-with-blur (if blur? :blue theme)
|
||||
(let [theme-with-blur (if blur? :blur theme)
|
||||
matcher [theme-with-blur type]]
|
||||
(case matcher
|
||||
([:dark :main] [:light :main]) (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
(ns react-native.net-info
|
||||
(:require
|
||||
["@react-native-community/netinfo" :default net-info]))
|
||||
|
||||
(defn add-net-info-listener
|
||||
[callback]
|
||||
(when net-info
|
||||
(.addEventListener ^js net-info callback)))
|
|
@ -0,0 +1,24 @@
|
|||
(ns status-im.common.data-confirmation-sheet.style
|
||||
(:require [quo.foundations.colors :as colors]))
|
||||
|
||||
(def heading
|
||||
{:padding-left 20
|
||||
:padding-bottom 8})
|
||||
|
||||
(def message
|
||||
{:padding-horizontal 20
|
||||
:padding-top 4})
|
||||
|
||||
(def warning
|
||||
{:margin-horizontal 20
|
||||
:margin-top 10})
|
||||
|
||||
(def drawer-container
|
||||
{:padding-horizontal 13
|
||||
:padding-top 16})
|
||||
|
||||
(def settings-subtext
|
||||
{:color colors/white-opa-70
|
||||
:align-self :center
|
||||
:margin-bottom 12})
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
(ns status-im.common.data-confirmation-sheet.view
|
||||
(:require
|
||||
[quo.core :as quo]
|
||||
[react-native.core :as rn]
|
||||
[status-im.common.data-confirmation-sheet.style :as style]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.navigation :as navigation]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn on-choice-callback
|
||||
[syncing-on-mobile-network?]
|
||||
(rf/dispatch [:network/set-syncing-on-mobile-network syncing-on-mobile-network?])
|
||||
(navigation/hide-bottom-sheet))
|
||||
|
||||
(def on-wifi-only (partial on-choice-callback false))
|
||||
(def on-mobile-and-wifi (partial on-choice-callback true))
|
||||
|
||||
(defn view
|
||||
[]
|
||||
(let [settings-drawer? (= (rf/sub [:view-id]) :screen/settings.syncing)
|
||||
syncing-on-mobile-network? (rf/sub [:profile/syncing-on-mobile-network?])]
|
||||
(rn/use-mount navigation/dismiss-keyboard)
|
||||
[:<>
|
||||
[quo/text
|
||||
{:weight :semi-bold
|
||||
:size :heading-2
|
||||
:accessibility-label :data-confirmation-sheet-heading
|
||||
:style style/heading}
|
||||
(i18n/label (if settings-drawer? :t/sync-and-backup :t/which-connection-to-use))]
|
||||
[quo/text
|
||||
{:weight :regular
|
||||
:size :paragraph-1
|
||||
:accessibility-label :data-confirmation-sheet-message
|
||||
:style style/message}
|
||||
(i18n/label :t/syncing-connection-message)]
|
||||
[quo/information-box
|
||||
{:type :default
|
||||
:icon :i/info
|
||||
:blur? true
|
||||
:style style/warning}
|
||||
(i18n/label :t/syncing-wifi-connection-warning)]
|
||||
(if settings-drawer?
|
||||
[rn/view {:style style/drawer-container}
|
||||
[quo/drawer-action
|
||||
{:title (i18n/label :t/mobile-data-and-wifi)
|
||||
:state (when syncing-on-mobile-network? :selected)
|
||||
:blur? true
|
||||
:accessibility-label :mobile-data-and-wifi-action
|
||||
:icon :i/connection
|
||||
:on-press on-mobile-and-wifi}]
|
||||
[quo/drawer-action
|
||||
{:title (i18n/label :t/wifi-only)
|
||||
:state (when-not syncing-on-mobile-network? :selected)
|
||||
:blur? true
|
||||
:accessibility-label :wifi-only-action
|
||||
:icon :i/placeholder
|
||||
:on-press on-wifi-only}]]
|
||||
[quo/bottom-actions
|
||||
{:actions :two-actions
|
||||
:blur? true
|
||||
:container-style {:margin-top 12}
|
||||
:button-one-label (i18n/label :t/wifi-only)
|
||||
:button-one-props {:type :grey
|
||||
:on-press on-wifi-only}
|
||||
:button-two-label (i18n/label :t/mobile-and-wifi)
|
||||
:button-two-props {:on-press on-mobile-and-wifi}}])
|
||||
(if settings-drawer?
|
||||
[quo/divider-line {:container-style {:padding-vertical 8}}]
|
||||
[quo/text
|
||||
{:weight :regular
|
||||
:size :paragraph-2
|
||||
:style style/settings-subtext}
|
||||
(i18n/label :t/you-can-change-later-in-settings)])]))
|
|
@ -1,7 +1,6 @@
|
|||
(ns status-im.common.signals.events
|
||||
(:require
|
||||
[legacy.status-im.chat.models.message :as models.message]
|
||||
[legacy.status-im.mailserver.core :as mailserver]
|
||||
[legacy.status-im.visibility-status-updates.core :as visibility-status-updates]
|
||||
[oops.core :as oops]
|
||||
[status-im.common.pairing.events :as pairing]
|
||||
|
@ -66,15 +65,6 @@
|
|||
"messages.new"
|
||||
(messages.transport/sanitize-messages-and-process-response cofx event-js true)
|
||||
|
||||
"mailserver.changed"
|
||||
(mailserver/handle-mailserver-changed cofx (oops/oget event-js :id))
|
||||
|
||||
"mailserver.available"
|
||||
(mailserver/handle-mailserver-available cofx (oops/oget event-js :id))
|
||||
|
||||
"mailserver.not.working"
|
||||
(mailserver/handle-mailserver-not-working cofx)
|
||||
|
||||
"discovery.summary"
|
||||
(summary cofx (transforms/js->clj event-js))
|
||||
|
||||
|
|
|
@ -125,6 +125,9 @@
|
|||
(def fetch-messages-enabled? (enabled? (get-config :FETCH_MESSAGES_ENABLED "1")))
|
||||
(def test-networks-enabled? (enabled? (get-config :TEST_NETWORKS_ENABLED "0")))
|
||||
|
||||
(def mobile-data-syncing-toggle-enabled?
|
||||
(enabled? (get-config :MOBILE_DATA_SYNCING_TOGGLE_ENABLE "1")))
|
||||
|
||||
;; Alert banners are disabled for debug builds because alert banners overlay
|
||||
;; interfere with react-native debug tools, such as inspector and Perf monitor
|
||||
(def enable-alert-banner? (enabled? (get-config :ENABLE_ALERT_BANNER "0")))
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
(:require
|
||||
[clojure.string :as string]
|
||||
[legacy.status-im.data-store.communities :as data-store.communities]
|
||||
[legacy.status-im.mailserver.core :as mailserver]
|
||||
[schema.core :as schema]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.contexts.chat.messenger.messages.link-preview.events :as link-preview.events]
|
||||
|
@ -288,8 +287,7 @@
|
|||
(when-let [community (first communities)]
|
||||
{:db (-> db
|
||||
(assoc-in [:communities (:id community) :spectated] true))
|
||||
:fx [[:dispatch [:communities/handle-community community]]
|
||||
[:dispatch [::mailserver/request-messages]]]}))
|
||||
:fx [[:dispatch [:communities/handle-community community]]]}))
|
||||
|
||||
(rf/reg-event-fx :chat.ui/spectate-community-success spectate-community-success)
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
(ns status-im.contexts.communities.events-test
|
||||
(:require [cljs.test :refer [deftest is testing]]
|
||||
[legacy.status-im.mailserver.core :as mailserver]
|
||||
matcher-combinators.test
|
||||
[status-im.contexts.chat.messenger.messages.link-preview.events :as link-preview.events]
|
||||
[status-im.contexts.communities.events :as events]))
|
||||
|
@ -112,7 +111,7 @@
|
|||
(testing "dispatch fxs for first community"
|
||||
(is (match?
|
||||
{:fx [[:dispatch [:communities/handle-community {:id community-id}]]
|
||||
[:dispatch [::mailserver/request-messages]]]}
|
||||
]}
|
||||
(events/spectate-community-success {} [{:communities [{:id community-id}]}])))))
|
||||
(testing "given empty community"
|
||||
(testing "do nothing"
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
(ns status-im.contexts.network.effects
|
||||
(:require
|
||||
[native-module.core :as native-module]
|
||||
[react-native.net-info :as net-info]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(rf/reg-fx
|
||||
:effects.network/listen-to-network-info
|
||||
(fn []
|
||||
(net-info/add-net-info-listener
|
||||
#(rf/dispatch [:network/on-state-change
|
||||
(js->clj % :keywordize-keys true)]))))
|
||||
|
||||
(rf/reg-fx
|
||||
:effects.network/notify-status-go
|
||||
(fn [network-type expensive?]
|
||||
(native-module/connection-change network-type expensive?)))
|
|
@ -0,0 +1,77 @@
|
|||
(ns status-im.contexts.network.events
|
||||
(:require
|
||||
[status-im.common.data-confirmation-sheet.view :as data-confirmation-sheet]
|
||||
[status-im.config :as config]
|
||||
[status-im.feature-flags :as ff]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(rf/reg-event-fx :network/set-syncing-on-mobile-network
|
||||
(fn [{:keys [db]} [syncing-on-mobile-network?]]
|
||||
(when config/mobile-data-syncing-toggle-enabled?
|
||||
{:db (update db
|
||||
:profile/profile
|
||||
assoc
|
||||
:syncing-on-mobile-network?
|
||||
syncing-on-mobile-network?
|
||||
:remember-syncing-choice?
|
||||
true)
|
||||
:fx [[:json-rpc/call
|
||||
[{:method "wakuext_setSyncingOnMobileNetwork"
|
||||
:params [{:enabled syncing-on-mobile-network?}]
|
||||
:on-success #(log/debug "successfully set syncing-on-mobile-network"
|
||||
syncing-on-mobile-network?)
|
||||
:on-error #(log/error "could not set syncing-on-mobile-network" %)}]]]})))
|
||||
|
||||
(rf/reg-event-fx :network/check-expensive-connection
|
||||
(fn [{:keys [db]}]
|
||||
(when
|
||||
(and (:network/expensive? db)
|
||||
config/mobile-data-syncing-toggle-enabled?
|
||||
(:profile/profile db)
|
||||
(not (get-in db [:profile/profile :remember-syncing-choice?])))
|
||||
;; Note here we are only updating :remember-syncing-choice? temporarily to avoid opening
|
||||
;; multiple bottom sheets and the user might again see the sheet on the next login. Unless the
|
||||
;; user makes a syncing choice that will persist this key in the status-go
|
||||
{:db (assoc-in db [:profile/profile :remember-syncing-choice?] true)
|
||||
:fx [[:dispatch
|
||||
[:show-bottom-sheet
|
||||
{:content (fn [] [data-confirmation-sheet/view])
|
||||
:shell? true
|
||||
:theme :dark}]]]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:network/on-state-change
|
||||
(fn [{:keys [db]} [{:keys [isConnected type details]}]]
|
||||
(let [old-network-status (:network/status db)
|
||||
old-network-type (:network/type db)
|
||||
connectivity-status (if isConnected :online :offline)
|
||||
status-changed? (not= connectivity-status old-network-status)
|
||||
type-changed? (not= type old-network-type)
|
||||
expensive? (:isConnectionExpensive details)]
|
||||
(log/debug "[net-info]"
|
||||
"old-network-status" old-network-status
|
||||
"old-network-type" old-network-type
|
||||
"connectivity-status" connectivity-status
|
||||
"type" type
|
||||
"details" details)
|
||||
{:db (assoc db :network/expensive? expensive?)
|
||||
:fx [[:dispatch [:network/check-expensive-connection]]
|
||||
(when status-changed?
|
||||
[:dispatch [:network/on-network-status-change connectivity-status]])
|
||||
(when type-changed?
|
||||
[:dispatch [:network/on-network-type-change type expensive?]])]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:network/on-network-type-change
|
||||
(fn [{:keys [db]} [network-type expensive?]]
|
||||
{:db (assoc db :network/type network-type)
|
||||
:fx [[:effects.network/notify-status-go network-type expensive?]
|
||||
[:dispatch [:network/on-network-status-change]]]}))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:network/on-network-status-change
|
||||
(fn [{:keys [db]} [connectivity-status]]
|
||||
{:db (assoc db :network/status connectivity-status)
|
||||
:fx [(when (ff/enabled? ::ff/wallet.wallet-connect)
|
||||
[:dispatch [:wallet-connect/reload-on-network-change (= :online connectivity-status)]])]}))
|
|
@ -1,55 +0,0 @@
|
|||
(ns status-im.contexts.networks.events
|
||||
(:require
|
||||
["@react-native-community/netinfo" :default net-info]
|
||||
[native-module.core :as native-module]
|
||||
[status-im.feature-flags :as ff]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(rf/reg-fx
|
||||
:effects.network/listen-to-network-info
|
||||
(fn []
|
||||
(when net-info
|
||||
(.addEventListener ^js net-info
|
||||
#(rf/dispatch [:network/on-state-change
|
||||
(js->clj % :keywordize-keys true)])))))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:network/on-state-change
|
||||
(fn [{:keys [db]} [{:keys [isConnected type details]}]]
|
||||
(let [old-network-status (:network/status db)
|
||||
old-network-type (:network/type db)
|
||||
connectivity-status (if isConnected :online :offline)
|
||||
status-changed? (not= connectivity-status old-network-status)
|
||||
type-changed? (not= type old-network-type)
|
||||
is-connection-expensive? (:is-connection-expensive details)]
|
||||
(log/debug "[net-info]"
|
||||
"old-network-status" old-network-status
|
||||
"old-network-type" old-network-type
|
||||
"connectivity-status" connectivity-status
|
||||
"type" type
|
||||
"details" details)
|
||||
{:fx [(when status-changed?
|
||||
[:dispatch [:network/on-network-status-change isConnected]])
|
||||
(when type-changed?
|
||||
[:dispatch [:network/on-network-type-change type is-connection-expensive?]])]})))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:network/on-network-type-change
|
||||
(fn [{:keys [db]} [network-type expensive?]]
|
||||
{:db (assoc db :network/type network-type)
|
||||
:fx [[:effects.network/notify-status-go network-type expensive?]
|
||||
[:dispatch [:mobile-network/on-network-status-change]]]}))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:network/on-network-status-change
|
||||
(fn [{:keys [db]} [is-connected?]]
|
||||
(let [network-status (if is-connected? :online :offline)]
|
||||
{:db (assoc db :network/status network-status)
|
||||
:fx [(when (ff/enabled? ::ff/wallet.wallet-connect)
|
||||
[:dispatch [:wallet-connect/reload-on-network-change is-connected?]])]})))
|
||||
|
||||
(rf/reg-fx
|
||||
:effects.network/notify-status-go
|
||||
(fn [network-type expensive?]
|
||||
(native-module/connection-change network-type expensive?)))
|
|
@ -1,7 +1,6 @@
|
|||
(ns status-im.contexts.profile.login.events
|
||||
(:require
|
||||
[legacy.status-im.data-store.settings :as data-store.settings]
|
||||
[legacy.status-im.mailserver.core :as mailserver]
|
||||
[native-module.core :as native-module]
|
||||
[status-im.common.keychain.events :as keychain]
|
||||
[status-im.config :as config]
|
||||
|
@ -99,7 +98,7 @@
|
|||
;; thread to process more important events first, but we can't delay
|
||||
;; too much otherwise the UX may degrade due to stale data.
|
||||
[:dispatch-later [{:ms 1500 :dispatch [:profile.login/non-critical-initialization]}]]
|
||||
[:dispatch [:mobile-network/on-network-status-change]]
|
||||
[:dispatch [:network/check-expensive-connection]]
|
||||
[:profile.settings/get-profile-picture key-uid]
|
||||
(when (ff/enabled? ::ff/wallet.wallet-connect)
|
||||
[:dispatch [:wallet-connect/init]])
|
||||
|
@ -131,11 +130,9 @@
|
|||
:on-error #(log/error "node-info: failed error" %)}]]]})))
|
||||
|
||||
(rf/reg-event-fx :profile.login/messenger-started
|
||||
(fn [{:keys [db]} [{:keys [mailservers]}]]
|
||||
(fn [{:keys [db]} [_]]
|
||||
(let [new-account? (get db :onboarding/new-account?)]
|
||||
{:db (-> db
|
||||
(assoc :messenger/started? true)
|
||||
(mailserver/add-mailservers mailservers))
|
||||
{:db (assoc db :messenger/started? true)
|
||||
:fx [[:fetch-chats-preview
|
||||
{:on-success (fn [result]
|
||||
(rf/dispatch [:chats-list/load-success result])
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
:blur? true
|
||||
:action :arrow}
|
||||
{:title (i18n/label :t/syncing)
|
||||
:on-press #(rf/dispatch [:open-modal :settings-syncing])
|
||||
:on-press #(rf/dispatch [:open-modal :screen/settings.syncing])
|
||||
:image-props :i/syncing
|
||||
:image :icon
|
||||
:blur? true
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
(ns status-im.contexts.profile.settings.screens.syncing.view
|
||||
(:require
|
||||
[quo.core :as quo]
|
||||
[status-im.common.data-confirmation-sheet.view :as data-confirmation-sheet]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.navigation :as navigation]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn- open-paired-devices-list
|
||||
[]
|
||||
(rf/dispatch [:open-modal :screen/paired-devices]))
|
||||
|
||||
(defn- open-data-confirmation-sheet
|
||||
[]
|
||||
(rf/dispatch
|
||||
[:show-bottom-sheet
|
||||
{:content (fn [] [data-confirmation-sheet/view])
|
||||
:shell? true
|
||||
:theme :dark}]))
|
||||
|
||||
(defn view
|
||||
[]
|
||||
(let [pairing-devices-count (rf/sub [:pairing/paired-devices-count])
|
||||
syncing-on-mobile-network? (rf/sub [:profile/syncing-on-mobile-network?])]
|
||||
[quo/overlay {:type :shell :top-inset? true}
|
||||
[quo/page-nav
|
||||
{:background :blur
|
||||
:icon-name :i/arrow-left
|
||||
:on-press navigation/navigate-back}]
|
||||
[quo/page-top {:title (i18n/label :t/syncing)}]
|
||||
[quo/category
|
||||
{:data [{:title (i18n/label :t/sync-and-backup)
|
||||
:description :text
|
||||
:description-props {:text (if syncing-on-mobile-network?
|
||||
(i18n/label :t/wifi-and-mobile-data)
|
||||
(i18n/label :t/mobile-network-use-wifi))}
|
||||
:on-press open-data-confirmation-sheet
|
||||
:blur? true
|
||||
:image-props :i/syncing
|
||||
:image :icon
|
||||
:action :arrow}
|
||||
{:title (i18n/label :t/paired-devices)
|
||||
:description :text
|
||||
:description-props {:text (i18n/label :t/devices-count
|
||||
{:number pairing-devices-count})}
|
||||
:on-press open-paired-devices-list
|
||||
:image-props :i/mobile
|
||||
:image :icon
|
||||
:blur? true
|
||||
:action :arrow}]
|
||||
:blur? true
|
||||
:list-type :settings}]]))
|
|
@ -54,7 +54,7 @@
|
|||
{:size :heading-1
|
||||
:weight :semi-bold
|
||||
:style {:color colors/white}}
|
||||
(i18n/label :t/syncing)]
|
||||
(i18n/label :t/paired-devices)]
|
||||
[quo/button
|
||||
{:size 32
|
||||
:type :primary
|
||||
|
|
|
@ -27,7 +27,8 @@
|
|||
status-im.contexts.contact.blocking.events
|
||||
status-im.contexts.keycard.effects
|
||||
status-im.contexts.keycard.events
|
||||
status-im.contexts.networks.events
|
||||
status-im.contexts.network.effects
|
||||
status-im.contexts.network.events
|
||||
status-im.contexts.onboarding.common.overlay.events
|
||||
status-im.contexts.onboarding.events
|
||||
status-im.contexts.profile.events
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
change-password-loading]
|
||||
[status-im.contexts.profile.settings.screens.password.change-password.view :as change-password]
|
||||
[status-im.contexts.profile.settings.screens.password.view :as settings-password]
|
||||
[status-im.contexts.profile.settings.screens.syncing.view :as settings.syncing]
|
||||
[status-im.contexts.profile.settings.view :as settings]
|
||||
[status-im.contexts.settings.privacy-and-security.view :as settings.privacy-and-security]
|
||||
[status-im.contexts.settings.wallet.keypairs-and-accounts.missing-keypairs.encrypted-qr.view
|
||||
|
@ -84,7 +85,7 @@
|
|||
[status-im.contexts.syncing.how-to-pair.view :as how-to-pair]
|
||||
[status-im.contexts.syncing.scan-sync-code-page.view :as scan-sync-code-page]
|
||||
[status-im.contexts.syncing.setup-syncing.view :as settings-setup-syncing]
|
||||
[status-im.contexts.syncing.syncing-devices-list.view :as settings-syncing]
|
||||
[status-im.contexts.syncing.syncing-devices-list.view :as syncing-devices-list]
|
||||
[status-im.contexts.wallet.account.edit-account.view :as wallet-edit-account]
|
||||
[status-im.contexts.wallet.account.share-address.view :as wallet-share-address]
|
||||
[status-im.contexts.wallet.account.view :as wallet-accounts]
|
||||
|
@ -241,9 +242,9 @@
|
|||
:options options/transparent-screen-options
|
||||
:component settings/view}
|
||||
|
||||
{:name :settings-syncing
|
||||
{:name :screen/paired-devices
|
||||
:options options/transparent-modal-screen-options
|
||||
:component settings-syncing/view}
|
||||
:component syncing-devices-list/view}
|
||||
|
||||
{:name :settings-setup-syncing
|
||||
:options options/transparent-screen-options
|
||||
|
@ -625,6 +626,10 @@
|
|||
:options options/transparent-modal-screen-options
|
||||
:component settings.messages/view}
|
||||
|
||||
{:name :screen/settings.syncing
|
||||
:options options/transparent-modal-screen-options
|
||||
:component settings.syncing/view}
|
||||
|
||||
{:name :screen/settings-blocked-users
|
||||
:options options/transparent-modal-screen-options
|
||||
:component settings.blocked-users/view}
|
||||
|
|
|
@ -12,6 +12,12 @@
|
|||
vals
|
||||
(pairing/sort-installations installation-id))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:pairing/paired-devices-count
|
||||
:<- [:pairing/installations]
|
||||
(fn [installations]
|
||||
(count (filter :enabled? (rest installations)))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:pairing/enabled-installations
|
||||
:<- [:pairing/installations]
|
||||
|
|
|
@ -24,6 +24,12 @@
|
|||
(fn [{:keys [currency]}]
|
||||
(or currency constants/profile-default-currency)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:profile/syncing-on-mobile-network?
|
||||
:<- [:profile/profile]
|
||||
(fn [{:keys [syncing-on-mobile-network?]}]
|
||||
(boolean syncing-on-mobile-network?)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
:profile/currency-symbol
|
||||
:<- [:profile/currency]
|
||||
|
|
|
@ -6,3 +6,11 @@
|
|||
(defn navigate-back
|
||||
[]
|
||||
(rf/dispatch [:navigate-back]))
|
||||
|
||||
(defn hide-bottom-sheet
|
||||
[]
|
||||
(rf/dispatch [:hide-bottom-sheet]))
|
||||
|
||||
(defn dismiss-keyboard
|
||||
[]
|
||||
(rf/dispatch [:dismiss-keyboard]))
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
(ns legacy.status-im.network.core
|
||||
(ns utils.network.core
|
||||
(:require
|
||||
[clojure.string :as string]))
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
(ns legacy.status-im.network.core-test
|
||||
(ns utils.network.core-test
|
||||
(:require
|
||||
[cljs.test :refer-macros [deftest is testing]]
|
||||
[legacy.status-im.network.core :as network.core]))
|
||||
[utils.network.core :as network.core]))
|
||||
|
||||
(deftest valid-rpc-url-test
|
||||
(testing "nil?"
|
|
@ -3,7 +3,7 @@
|
|||
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
||||
"owner": "status-im",
|
||||
"repo": "status-go",
|
||||
"version": "v0.182.38",
|
||||
"commit-sha1": "2bbdb35f6cabd1a4f7775e180e0647b70ce8d1aa",
|
||||
"src-sha256": "03bksi5gn44ky76kblikpr6j3x69baid81ghfk27a4qx9hnc0qgc"
|
||||
"version": "v0.182.39",
|
||||
"commit-sha1": "9755b3de7ae64929066d2b8a26222d8d41ceda87",
|
||||
"src-sha256": "02b2fshb7phhsr7mghg4s6qr1n1c8xawaz4pw04q8hpv5vfnjcxz"
|
||||
}
|
||||
|
|
|
@ -744,6 +744,7 @@
|
|||
"dev-mode-settings": "Development mode settings",
|
||||
"device-syncing": "Device syncing",
|
||||
"devices": "Devices",
|
||||
"devices-count": "{{number}} devices",
|
||||
"disable": "disable",
|
||||
"disable-all": "Disable all",
|
||||
"disable-later-in-settings": "You can disable this later in Settings",
|
||||
|
@ -1544,6 +1545,8 @@
|
|||
"mint": "Mint",
|
||||
"mo": "Mo",
|
||||
"mobile": "Mobile",
|
||||
"mobile-and-wifi": "Mobile and Wi-Fi",
|
||||
"mobile-data-and-wifi": "Mobile data and Wi-Fi",
|
||||
"mobile-network-ask-me": "Ask me when on mobile network",
|
||||
"mobile-network-continue-syncing": "Continue syncing",
|
||||
"mobile-network-continue-syncing-details": "You can change this later in settings",
|
||||
|
@ -2351,6 +2354,7 @@
|
|||
"switch-to-simple-interface": "Switch to simple interface",
|
||||
"symbol": "Symbol",
|
||||
"sync-all-devices": "Sync all devices",
|
||||
"sync-and-backup": "Sync and backup",
|
||||
"sync-code": "Sync Code",
|
||||
"sync-code-generated": "Sync code generated",
|
||||
"sync-devices-complete-sub-title": "Your devices are now in sync",
|
||||
|
@ -2369,7 +2373,9 @@
|
|||
"synced-with": "Synced with",
|
||||
"synchronise-your-data-across-your-devices": "Synchronise your data across your devices",
|
||||
"syncing": "Syncing",
|
||||
"syncing-connection-message": "App uses a lot of data when syncing and making backups. If you have a limited data plan, consider syncing over Wi-Fi only. ",
|
||||
"syncing-devices": "Syncing...",
|
||||
"syncing-wifi-connection-warning": "If you choose to sync over Wi-Fi only, messages sent to you while you are offline will be delivered once you connect to Wi-Fi.",
|
||||
"system": "System",
|
||||
"tabs": "Tabs",
|
||||
"tag-was-lost": "Tag was lost",
|
||||
|
@ -2705,7 +2711,10 @@
|
|||
"what-we-will-receive": "What we will receive:",
|
||||
"what-we-wont-receive": "What we won't receive:",
|
||||
"whats-on-your-mind": "What’s on your mind…",
|
||||
"which-connection-to-use": "Which connection to use for syncing?",
|
||||
"who-are-you-looking-for": "Who are you looking for ?",
|
||||
"wifi-and-mobile-data": "Wi-Fi and mobile data",
|
||||
"wifi-only": "Wi-Fi only",
|
||||
"with-full-encryption": "With full metadata privacy and e2e encryption",
|
||||
"word-count": "Word count",
|
||||
"word-n": "Word #{{number}}",
|
||||
|
@ -2734,6 +2743,7 @@
|
|||
"you-are-all-set": "You’re all set!",
|
||||
"you-are-all-set-description": "If you lose your phone, you can now access your funds and chat key using your seed phrase",
|
||||
"you-can-change-account": "You can change the account name and color to what you wish",
|
||||
"you-can-change-later-in-settings": "You can always change it later in Settings",
|
||||
"you-can-choose-preview-websites": "You can choose which of the following websites can preview link of descriptions and pictures in chats",
|
||||
"you-can-fetch": "You can fetch chat history",
|
||||
"you-canceled-the-request": "You canceled the request to join",
|
||||
|
|
Loading…
Reference in New Issue