mirror of
https://github.com/status-im/status-react.git
synced 2025-01-09 18:46:19 +00:00
Move mailserver logic to status-go
598b83757c...d60a6713fe
Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
parent
c69b640810
commit
60cfca1107
@ -10,13 +10,6 @@ make shell TARGET=android
|
|||||||
```
|
```
|
||||||
This step will take a while the first time as it will download all dependencies.
|
This step will take a while the first time as it will download all dependencies.
|
||||||
|
|
||||||
To build the app, your can simply run on of the following:
|
|
||||||
```
|
|
||||||
make release-android
|
|
||||||
make release-ios
|
|
||||||
```
|
|
||||||
For more `make` targets run `make help`.
|
|
||||||
|
|
||||||
# Development
|
# Development
|
||||||
|
|
||||||
There are three steps necessary to start development, in this case for Android:
|
There are three steps necessary to start development, in this case for Android:
|
||||||
@ -28,6 +21,18 @@ There are three steps necessary to start development, in this case for Android:
|
|||||||
The first two will continue watching for changes and keep re-building the app. They need to be ready first.
|
The first two will continue watching for changes and keep re-building the app. They need to be ready first.
|
||||||
The last one will exit once the app is up and ready.
|
The last one will exit once the app is up and ready.
|
||||||
|
|
||||||
|
You need to have your emulator or real devices running and visible to adb, before you run `make run-android`.
|
||||||
|
|
||||||
|
# Build release
|
||||||
|
|
||||||
|
To build the app, your can simply run on of the following:
|
||||||
|
```
|
||||||
|
make release-android
|
||||||
|
make release-ios
|
||||||
|
```
|
||||||
|
|
||||||
|
For more `make` targets run `make help`.
|
||||||
|
|
||||||
# Updating Dependencies
|
# Updating Dependencies
|
||||||
|
|
||||||
* `make nix-update-pods` - iOS CocoaPods dependencies (updates `ios/Podfile` and `ios/Podfile.loc`)
|
* `make nix-update-pods` - iOS CocoaPods dependencies (updates `ios/Podfile` and `ios/Podfile.loc`)
|
||||||
|
@ -169,8 +169,7 @@
|
|||||||
(fx/defn update-message-status
|
(fx/defn update-message-status
|
||||||
[{:keys [db] :as cofx} chat-id message-id status]
|
[{:keys [db] :as cofx} chat-id message-id status]
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
(update-db-message-status chat-id message-id status)
|
(update-db-message-status chat-id message-id status)))
|
||||||
(data-store.messages/update-outgoing-status message-id status)))
|
|
||||||
|
|
||||||
(fx/defn resend-message
|
(fx/defn resend-message
|
||||||
[{:keys [db] :as cofx} chat-id message-id]
|
[{:keys [db] :as cofx} chat-id message-id]
|
||||||
|
@ -49,12 +49,6 @@
|
|||||||
:outgoing (boolean (:outgoingStatus message)))
|
:outgoing (boolean (:outgoingStatus message)))
|
||||||
(dissoc :ensName :chatId :text :rtl :responseTo :image :sticker :lineCount :parsedText :links)))
|
(dissoc :ensName :chatId :text :rtl :responseTo :image :sticker :lineCount :parsedText :links)))
|
||||||
|
|
||||||
(defn update-outgoing-status-rpc [message-id status]
|
|
||||||
{::json-rpc/call [{:method (json-rpc/call-ext-method "updateMessageOutgoingStatus")
|
|
||||||
:params [message-id status]
|
|
||||||
:on-success #(log/debug "updated message outgoing stauts" message-id status)
|
|
||||||
:on-failure #(log/error "failed to update message outgoing status" message-id status %)}]})
|
|
||||||
|
|
||||||
(defn messages-by-chat-id-rpc [chat-id
|
(defn messages-by-chat-id-rpc [chat-id
|
||||||
cursor
|
cursor
|
||||||
limit
|
limit
|
||||||
@ -101,8 +95,5 @@
|
|||||||
(fx/defn mark-messages-seen [cofx chat-id ids on-success]
|
(fx/defn mark-messages-seen [cofx chat-id ids on-success]
|
||||||
(mark-seen-rpc chat-id ids on-success))
|
(mark-seen-rpc chat-id ids on-success))
|
||||||
|
|
||||||
(fx/defn update-outgoing-status [cofx message-id status]
|
|
||||||
(update-outgoing-status-rpc message-id status))
|
|
||||||
|
|
||||||
(fx/defn delete-messages-by-chat-id [cofx chat-id]
|
(fx/defn delete-messages-by-chat-id [cofx chat-id]
|
||||||
(delete-messages-by-chat-id-rpc chat-id))
|
(delete-messages-by-chat-id-rpc chat-id))
|
||||||
|
@ -46,7 +46,8 @@
|
|||||||
"waku_getSymKey" {}
|
"waku_getSymKey" {}
|
||||||
"waku_markTrustedPeer" {}
|
"waku_markTrustedPeer" {}
|
||||||
"wakuext_post" {}
|
"wakuext_post" {}
|
||||||
"wakuext_requestAllHistoricMessages" {}
|
"wakuext_requestAllHistoricMessagesWithRetries" {}
|
||||||
|
"wakuext_toggleUseMailservers" {}
|
||||||
"wakuext_editMessage" {}
|
"wakuext_editMessage" {}
|
||||||
"wakuext_deleteMessageAndSend" {}
|
"wakuext_deleteMessageAndSend" {}
|
||||||
"wakuext_fillGaps" {}
|
"wakuext_fillGaps" {}
|
||||||
@ -93,7 +94,6 @@
|
|||||||
"wakuext_markAllRead" {}
|
"wakuext_markAllRead" {}
|
||||||
"wakuext_markAllReadInCommunity" {}
|
"wakuext_markAllReadInCommunity" {}
|
||||||
"wakuext_confirmMessagesProcessedByID" {}
|
"wakuext_confirmMessagesProcessedByID" {}
|
||||||
"wakuext_updateMessageOutgoingStatus" {}
|
|
||||||
"wakuext_chatMessages" {}
|
"wakuext_chatMessages" {}
|
||||||
"wakuext_saveChat" {}
|
"wakuext_saveChat" {}
|
||||||
"wakuext_muteChat" {}
|
"wakuext_muteChat" {}
|
||||||
@ -108,6 +108,7 @@
|
|||||||
"wakuext_addContact" {}
|
"wakuext_addContact" {}
|
||||||
"wakuext_updateMailservers" {}
|
"wakuext_updateMailservers" {}
|
||||||
"wakuext_sendEmojiReaction" {}
|
"wakuext_sendEmojiReaction" {}
|
||||||
|
"wakuext_disconnectActiveMailserver" {}
|
||||||
"wakuext_sendEmojiReactionRetraction" {}
|
"wakuext_sendEmojiReactionRetraction" {}
|
||||||
"wakuext_emojiReactionsByChatID" {}
|
"wakuext_emojiReactionsByChatID" {}
|
||||||
"wakuext_getLinkPreviewWhitelist" {}
|
"wakuext_getLinkPreviewWhitelist" {}
|
||||||
@ -115,6 +116,7 @@
|
|||||||
"wakuext_requestCommunityInfoFromMailserver" {}
|
"wakuext_requestCommunityInfoFromMailserver" {}
|
||||||
"wakuext_deactivateChat" {}
|
"wakuext_deactivateChat" {}
|
||||||
"wakuext_sendPinMessage" {}
|
"wakuext_sendPinMessage" {}
|
||||||
|
"wakuext_setPinnedMailservers" {}
|
||||||
"wakuext_chatPinnedMessages" {}
|
"wakuext_chatPinnedMessages" {}
|
||||||
;;TODO not used anywhere?
|
;;TODO not used anywhere?
|
||||||
"wakuext_deleteChat" {}
|
"wakuext_deleteChat" {}
|
||||||
|
@ -4,15 +4,11 @@
|
|||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
[status-im.ethereum.json-rpc :as json-rpc]
|
[status-im.ethereum.json-rpc :as json-rpc]
|
||||||
[status-im.i18n.i18n :as i18n]
|
[status-im.i18n.i18n :as i18n]
|
||||||
[status-im.mailserver.constants :as constants]
|
|
||||||
[status-im.multiaccounts.update.core :as multiaccounts.update]
|
[status-im.multiaccounts.update.core :as multiaccounts.update]
|
||||||
[status-im.native-module.core :as status]
|
|
||||||
[status-im.node.core :as node]
|
[status-im.node.core :as node]
|
||||||
[status-im.utils.mobile-sync :as mobile-network-utils]
|
[status-im.utils.mobile-sync :as mobile-network-utils]
|
||||||
[status-im.navigation :as navigation]
|
[status-im.navigation :as navigation]
|
||||||
[status-im.utils.config :as config]
|
|
||||||
[status-im.utils.fx :as fx]
|
[status-im.utils.fx :as fx]
|
||||||
[status-im.utils.handlers :as handlers]
|
|
||||||
[taoensso.timbre :as log]))
|
[taoensso.timbre :as log]))
|
||||||
|
|
||||||
;; How do mailserver work ?
|
;; How do mailserver work ?
|
||||||
@ -31,14 +27,6 @@
|
|||||||
(defn connected? [db id]
|
(defn connected? [db id]
|
||||||
(= (:mailserver/current-id db) id))
|
(= (:mailserver/current-id db) id))
|
||||||
|
|
||||||
(def whisper-opts
|
|
||||||
{;; time drift that is tolerated by whisper, in seconds
|
|
||||||
:whisper-drift-tolerance 10
|
|
||||||
;; ttl of 10 sec
|
|
||||||
:ttl 10
|
|
||||||
:powTarget config/pow-target
|
|
||||||
:powTime config/pow-time})
|
|
||||||
|
|
||||||
(defn fetch [db id]
|
(defn fetch [db id]
|
||||||
(get-in db [:mailserver/mailservers (node/current-fleet-key db) id]))
|
(get-in db [:mailserver/mailservers (node/current-fleet-key db) id]))
|
||||||
|
|
||||||
@ -60,259 +48,33 @@
|
|||||||
current-fleet
|
current-fleet
|
||||||
vals)))))
|
vals)))))
|
||||||
|
|
||||||
(defn get-selected-mailserver
|
|
||||||
"Use the preferred mailserver if set & exists"
|
|
||||||
[db]
|
|
||||||
(let [preference (preferred-mailserver-id db)]
|
|
||||||
(when (and preference
|
|
||||||
(fetch db preference))
|
|
||||||
preference)))
|
|
||||||
|
|
||||||
;; We now wait for a confirmation from the mailserver before marking the message
|
|
||||||
;; as sent.
|
|
||||||
(defn update-mailservers! [enodes on-success]
|
|
||||||
(json-rpc/call
|
|
||||||
{:method (json-rpc/call-ext-method "updateMailservers")
|
|
||||||
:params [enodes]
|
|
||||||
:on-success #(do
|
|
||||||
(log/debug "mailserver: update-mailservers success" %)
|
|
||||||
(when on-success
|
|
||||||
(on-success)))
|
|
||||||
:on-error #(log/error "mailserver: update-mailservers error" %)}))
|
|
||||||
|
|
||||||
(defn remove-peer! [enode]
|
|
||||||
(let [args {:jsonrpc "2.0"
|
|
||||||
:id 2
|
|
||||||
:method "admin_removePeer"
|
|
||||||
:params [enode]}
|
|
||||||
payload (.stringify js/JSON (clj->js args))]
|
|
||||||
(when enode
|
|
||||||
(status/call-private-rpc payload
|
|
||||||
(handlers/response-handler
|
|
||||||
#(log/info "mailserver: remove-peer success" %)
|
|
||||||
#(log/error "mailserver: remove-peer error" %))))))
|
|
||||||
|
|
||||||
(re-frame/reg-fx
|
|
||||||
:mailserver/remove-peer
|
|
||||||
(fn [enode]
|
|
||||||
(remove-peer! enode)))
|
|
||||||
|
|
||||||
(re-frame/reg-fx
|
|
||||||
:mailserver/update-mailservers
|
|
||||||
(fn [[enodes on-success]]
|
|
||||||
(update-mailservers! enodes on-success)))
|
|
||||||
|
|
||||||
(defn registered-peer?
|
|
||||||
"truthy if the enode is a registered peer"
|
|
||||||
[peers enode]
|
|
||||||
(let [registered-enodes (into #{} (map :enode) peers)]
|
|
||||||
(contains? registered-enodes enode)))
|
|
||||||
|
|
||||||
(defn update-mailserver-state [db state]
|
|
||||||
(assoc db :mailserver/state state))
|
|
||||||
|
|
||||||
(fx/defn add-peer
|
|
||||||
[{:keys [db now] :as cofx}]
|
|
||||||
(let [{:keys [address] :as mailserver}
|
|
||||||
(fetch-current db)]
|
|
||||||
{:db (assoc
|
|
||||||
(update-mailserver-state db :connecting)
|
|
||||||
:mailserver/last-connection-attempt now)
|
|
||||||
;; Any message sent before this takes effect will not be marked as sent
|
|
||||||
;; probably we should improve the UX so that is more transparent to the
|
|
||||||
;; user
|
|
||||||
:mailserver/update-mailservers [[address]]}))
|
|
||||||
|
|
||||||
(fx/defn disconnect-from-mailserver
|
(fx/defn disconnect-from-mailserver
|
||||||
|
{:events [::disconnect-from-mailserver]}
|
||||||
[{:keys [db] :as cofx}]
|
[{:keys [db] :as cofx}]
|
||||||
(let [{:keys [address]} (fetch-current db)
|
{:db (-> db
|
||||||
{:keys [peers-summary]} db]
|
(assoc :mailserver/state nil)
|
||||||
{:db (dissoc db :mailserver/current-request :mailserver/fetching-gaps-in-progress)
|
(dissoc :mailserver/current-request :mailserver/fetching-gaps-in-progress))})
|
||||||
:mailserver/remove-peer address}))
|
|
||||||
|
|
||||||
(defn fetch-use-mailservers? [{:keys [db]}]
|
(defn fetch-use-mailservers? [{:keys [db]}]
|
||||||
(get-in db [:multiaccount :use-mailservers?]))
|
(get-in db [:multiaccount :use-mailservers?]))
|
||||||
|
|
||||||
(defn pool-size [fleet-size]
|
|
||||||
(.ceil js/Math (/ fleet-size 4)))
|
|
||||||
|
|
||||||
(fx/defn get-mailservers-latency
|
|
||||||
[{:keys [db] :as cofx}]
|
|
||||||
(let [current-fleet (node/current-fleet-key db)
|
|
||||||
addresses (mapv :address (-> db
|
|
||||||
:mailserver/mailservers
|
|
||||||
current-fleet
|
|
||||||
vals))]
|
|
||||||
{::json-rpc/call [{:method "mailservers_ping"
|
|
||||||
:params [{:addresses addresses
|
|
||||||
:timeoutMs 500}]
|
|
||||||
:on-success
|
|
||||||
#(re-frame/dispatch [::get-latency-callback %])}]}))
|
|
||||||
|
|
||||||
(fx/defn log-mailserver-failure [{:keys [db now]}]
|
|
||||||
(when-let [mailserver (fetch-current db)]
|
|
||||||
{:db (assoc-in db [:mailserver/failures (:address mailserver)] now)}))
|
|
||||||
|
|
||||||
(defn sort-mailservers
|
|
||||||
"Sort mailservers sorts the mailservers by recent failures, and by rtt
|
|
||||||
for breaking ties"
|
|
||||||
[{:keys [now db]} mailservers]
|
|
||||||
(let [mailserver-failures (:mailserver/failures db)
|
|
||||||
sort-fn (fn [a b]
|
|
||||||
(let [failures-a (get mailserver-failures (:address a))
|
|
||||||
failures-b (get mailserver-failures (:address b))
|
|
||||||
has-a-failed? (boolean
|
|
||||||
(and failures-a (<= (- now failures-a) constants/cooloff-period)))
|
|
||||||
has-b-failed? (boolean
|
|
||||||
(and failures-b (<= (- now failures-b) constants/cooloff-period)))]
|
|
||||||
;; If both have failed, or none of them, then compare rtt
|
|
||||||
(cond
|
|
||||||
(= has-a-failed? has-b-failed?)
|
|
||||||
(compare (:rttMs a) (:rttMs b))
|
|
||||||
;; Otherwise prefer the one that has not failed recently
|
|
||||||
has-a-failed? 1
|
|
||||||
has-b-failed? -1)))]
|
|
||||||
(sort sort-fn mailservers)))
|
|
||||||
|
|
||||||
(defn get-mailserver-when-ready
|
|
||||||
"return the mailserver if the mailserver is ready"
|
|
||||||
[{:keys [db]}]
|
|
||||||
(let [mailserver (fetch-current db)
|
|
||||||
mailserver-state (:mailserver/state db)]
|
|
||||||
(when (= :connected mailserver-state)
|
|
||||||
mailserver)))
|
|
||||||
|
|
||||||
(fx/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]})
|
|
||||||
|
|
||||||
(fx/defn process-next-messages-request
|
|
||||||
{:events [::request-messages]}
|
|
||||||
[{:keys [db now] :as cofx}]
|
|
||||||
(when (and
|
|
||||||
(:messenger/started? db)
|
|
||||||
(mobile-network-utils/syncing-allowed? cofx)
|
|
||||||
(fetch-use-mailservers? cofx)
|
|
||||||
(not (:mailserver/current-request db)))
|
|
||||||
(when-let [mailserver (get-mailserver-when-ready cofx)]
|
|
||||||
{:db (assoc db :mailserver/current-request true)
|
|
||||||
::json-rpc/call [{:method "wakuext_requestAllHistoricMessages"
|
|
||||||
:params []
|
|
||||||
:js-response true
|
|
||||||
:on-success #(do
|
|
||||||
(log/info "fetched historical messages")
|
|
||||||
(re-frame/dispatch [::request-success %]))
|
|
||||||
:on-failure #(log/error "failed retrieve historical messages" %)}]})))
|
|
||||||
|
|
||||||
(fx/defn connected-to-mailserver
|
|
||||||
[{:keys [db] :as cofx}]
|
|
||||||
(let [{:keys [address]} (fetch-current db)]
|
|
||||||
(fx/merge
|
|
||||||
cofx
|
|
||||||
{:db (update-mailserver-state db :connected)
|
|
||||||
:mailserver/update-mailservers [[address] #(re-frame/dispatch [::request-messages])]})))
|
|
||||||
|
|
||||||
(fx/defn connect-to-mailserver
|
|
||||||
"Add mailserver as a peer using `::add-peer` cofx and generate sym-key when
|
|
||||||
it doesn't exists
|
|
||||||
Peer summary will change and we will receive a signal from status go when
|
|
||||||
this is successful
|
|
||||||
A connection-check is made after `connection timeout` is reached and
|
|
||||||
mailserver-state is changed to error if it is not connected by then
|
|
||||||
No attempt is made if mailserver usage is disabled"
|
|
||||||
{:events [:mailserver.ui/reconnect-mailserver-pressed]}
|
|
||||||
[{:keys [db] :as cofx}]
|
|
||||||
(let [{:keys [address]} (fetch-current db)
|
|
||||||
{:keys [peers-summary]} db
|
|
||||||
use-mailservers? (fetch-use-mailservers? cofx)
|
|
||||||
added? (registered-peer? peers-summary address)]
|
|
||||||
(when use-mailservers?
|
|
||||||
(fx/merge cofx
|
|
||||||
{:db (dissoc db :mailserver/current-request)}
|
|
||||||
(if added?
|
|
||||||
(connected-to-mailserver)
|
|
||||||
(add-peer))))))
|
|
||||||
|
|
||||||
(fx/defn set-current-mailserver-with-lowest-latency
|
|
||||||
"Picks a random mailserver amongs the ones with the lowest latency
|
|
||||||
The results with error are ignored
|
|
||||||
The pool size is 1/4 of the mailservers were pinged successfully"
|
|
||||||
{:events [::get-latency-callback]}
|
|
||||||
[{:keys [db] :as cofx} latency-results]
|
|
||||||
(let [successful-pings (remove :error latency-results)]
|
|
||||||
(when (seq successful-pings)
|
|
||||||
(let [address (-> (take (pool-size (count successful-pings))
|
|
||||||
(sort-mailservers cofx successful-pings))
|
|
||||||
rand-nth
|
|
||||||
:address)
|
|
||||||
mailserver-id (mailserver-address->id db address)]
|
|
||||||
(fx/merge cofx
|
|
||||||
{:db (assoc db :mailserver/current-id mailserver-id)}
|
|
||||||
(connect-to-mailserver))))))
|
|
||||||
|
|
||||||
(fx/defn set-current-mailserver
|
|
||||||
[{:keys [db] :as cofx}]
|
|
||||||
(if-let [mailserver-id (get-selected-mailserver db)]
|
|
||||||
(fx/merge cofx
|
|
||||||
{:db (assoc db :mailserver/current-id mailserver-id)}
|
|
||||||
(connect-to-mailserver))
|
|
||||||
(get-mailservers-latency cofx)))
|
|
||||||
|
|
||||||
(fx/defn peers-summary-change
|
|
||||||
"There is only 2 summary changes that require mailserver action:
|
|
||||||
- mailserver disconnected: we try to reconnect
|
|
||||||
- mailserver connected: we mark the mailserver as trusted peer"
|
|
||||||
[{:keys [db] :as cofx} previous-summary]
|
|
||||||
(when (:multiaccount db)
|
|
||||||
(if (:mailserver/current-id db)
|
|
||||||
(let [{:keys [peers-summary peers-count]} db
|
|
||||||
{:keys [address] :as mailserver} (fetch-current db)
|
|
||||||
mailserver-was-registered? (registered-peer? previous-summary
|
|
||||||
address)
|
|
||||||
mailserver-is-registered? (registered-peer? peers-summary
|
|
||||||
address)
|
|
||||||
mailserver-added? (and mailserver-is-registered?
|
|
||||||
(not mailserver-was-registered?))
|
|
||||||
mailserver-removed? (and mailserver-was-registered?
|
|
||||||
(not mailserver-is-registered?))]
|
|
||||||
(cond
|
|
||||||
mailserver-added?
|
|
||||||
(connected-to-mailserver cofx)
|
|
||||||
mailserver-removed?
|
|
||||||
(connect-to-mailserver cofx)))
|
|
||||||
;; if there is no current mailserver defined
|
|
||||||
;; we set it first
|
|
||||||
(set-current-mailserver cofx))))
|
|
||||||
|
|
||||||
(fx/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)}))
|
|
||||||
|
|
||||||
(fx/defn update-use-mailservers
|
|
||||||
{:events [:mailserver.ui/use-history-switch-pressed]}
|
|
||||||
[cofx use-mailservers?]
|
|
||||||
(fx/merge cofx
|
|
||||||
(multiaccounts.update/multiaccount-update :use-mailservers? use-mailservers? {})
|
|
||||||
(if use-mailservers?
|
|
||||||
(connect-to-mailserver)
|
|
||||||
(disconnect-from-mailserver))))
|
|
||||||
|
|
||||||
(defonce showing-connection-error-popup? (atom false))
|
(defonce showing-connection-error-popup? (atom false))
|
||||||
|
|
||||||
(defn show-connection-error! [db current-fleet preferred-mailserver]
|
(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!)
|
||||||
|
|
||||||
|
(fx/defn show-connection-error! [cofx current-fleet preferred-mailserver]
|
||||||
(reset! showing-connection-error-popup? true)
|
(reset! showing-connection-error-popup? true)
|
||||||
(assoc db :ui/show-confirmation
|
{:ui/show-confirmation
|
||||||
{:title (i18n/label :t/mailserver-error-title)
|
{:title (i18n/label :t/mailserver-error-title)
|
||||||
:content (i18n/label :t/mailserver-error-content)
|
:content (i18n/label :t/mailserver-error-content)
|
||||||
:confirm-button-text (i18n/label :t/mailserver-pick-another)
|
:confirm-button-text (i18n/label :t/mailserver-pick-another)
|
||||||
:on-cancel #(do
|
:on-cancel cancel-connection-popup!
|
||||||
(reset! showing-connection-error-popup? false)
|
|
||||||
(re-frame/dispatch [:mailserver.ui/dismiss-connection-error true]))
|
|
||||||
:on-accept #(do
|
:on-accept #(do
|
||||||
(reset! showing-connection-error-popup? false)
|
(reset! showing-connection-error-popup? false)
|
||||||
(re-frame/dispatch [:mailserver.ui/dismiss-connection-error true])
|
(re-frame/dispatch [:mailserver.ui/dismiss-connection-error true])
|
||||||
@ -324,55 +86,90 @@
|
|||||||
[:mailserver.ui/connect-confirmed
|
[:mailserver.ui/connect-confirmed
|
||||||
current-fleet
|
current-fleet
|
||||||
preferred-mailserver]))
|
preferred-mailserver]))
|
||||||
:style "default"}]}))
|
:style "default"}]}})
|
||||||
|
|
||||||
(fx/defn change-mailserver
|
(fx/defn handle-successful-request
|
||||||
"mark mailserver status as `:error` if custom mailserver is used
|
{:events [::request-success]}
|
||||||
otherwise try to reconnect to another mailserver"
|
[{:keys [db] :as cofx} response-js]
|
||||||
|
{:db (dissoc db :mailserver/current-request)
|
||||||
|
:dispatch [:sanitize-messages-and-process-response response-js]})
|
||||||
|
|
||||||
|
(fx/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 [:multiaccount :pinned-mailservers current-fleet])]
|
||||||
|
(when (and pinned-mailserver
|
||||||
|
(not error-dismissed?)
|
||||||
|
(not @showing-connection-error-popup?))
|
||||||
|
(show-connection-error! cofx current-fleet pinned-mailserver))))
|
||||||
|
|
||||||
|
(fx/defn handle-request-error
|
||||||
|
{:events [::request-error]}
|
||||||
[{:keys [db] :as cofx}]
|
[{:keys [db] :as cofx}]
|
||||||
(when (and (fetch-use-mailservers? cofx)
|
{:db (dissoc db :mailserver/current-request)})
|
||||||
;; For some reason the tests are checking
|
|
||||||
;; for non-zero, so nil value is ok, not
|
|
||||||
;; sure is intentional, but will leave it as it is
|
|
||||||
;; instead of using pos?
|
|
||||||
(not (zero? (:peers-count db))))
|
|
||||||
(if-let [preferred-mailserver (preferred-mailserver-id db)]
|
|
||||||
(let [error-dismissed? (connection-error-dismissed db)
|
|
||||||
current-fleet (node/current-fleet-key db)]
|
|
||||||
;; Error connecting to the mail server
|
|
||||||
(cond-> {:db (update-mailserver-state db :error)}
|
|
||||||
(not (or error-dismissed? @showing-connection-error-popup?))
|
|
||||||
(show-connection-error! current-fleet preferred-mailserver)))
|
|
||||||
(let [{:keys [address]} (fetch-current db)]
|
|
||||||
(fx/merge cofx
|
|
||||||
{:mailserver/remove-peer address}
|
|
||||||
(set-current-mailserver))))))
|
|
||||||
|
|
||||||
(defn check-connection! []
|
(fx/defn process-next-messages-request
|
||||||
(re-frame/dispatch [:mailserver/check-connection-timeout]))
|
{:events [::request-messages]}
|
||||||
|
|
||||||
(fx/defn check-connection
|
|
||||||
"Check connection checks that the connection is successfully connected,
|
|
||||||
otherwise it will try to change mailserver and connect again"
|
|
||||||
{:events [:mailserver/check-connection-timeout]}
|
|
||||||
[{:keys [db now] :as cofx}]
|
[{:keys [db now] :as cofx}]
|
||||||
;; check if logged into multiaccount
|
(when (and
|
||||||
(when (contains? db :multiaccount)
|
(:messenger/started? db)
|
||||||
(let [last-connection-attempt (:mailserver/last-connection-attempt db)]
|
(mobile-network-utils/syncing-allowed? cofx)
|
||||||
(if (and (fetch-use-mailservers? cofx)
|
(fetch-use-mailservers? cofx)
|
||||||
;; We are not connected
|
(not (:mailserver/current-request db)))
|
||||||
(not= :connected (:mailserver/state db))
|
{:db (assoc db :mailserver/current-request true)
|
||||||
;; We either never tried to connect to this peer
|
::json-rpc/call [{:method "wakuext_requestAllHistoricMessagesWithRetries"
|
||||||
(or (nil? last-connection-attempt)
|
:params []
|
||||||
;; Or 30 seconds have passed and no luck
|
:js-response true
|
||||||
(>= (- now last-connection-attempt) (* constants/connection-timeout 3))))
|
:on-success #(do
|
||||||
;; Then we change mailserver
|
(log/info "fetched historical messages")
|
||||||
(change-mailserver cofx)
|
(re-frame/dispatch [::request-success %]))
|
||||||
;; Just make sure it's set
|
:on-error #(do
|
||||||
(let [{:keys [address] :as mailserver}
|
(log/error "failed retrieve historical messages" %)
|
||||||
(fetch-current db)]
|
(re-frame/dispatch [::request-error]))}]}))
|
||||||
(when address
|
|
||||||
{:mailserver/update-mailservers [[address]]}))))))
|
(fx/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)}))
|
||||||
|
|
||||||
|
(fx/defn handle-mailserver-available
|
||||||
|
[{:keys [db] :as cofx} ms]
|
||||||
|
{::cancel-connection-popup []
|
||||||
|
:db (assoc db :mailserver/state :connected
|
||||||
|
:mailserver/current-id (keyword ms))})
|
||||||
|
|
||||||
|
(fx/defn connected-to-mailserver
|
||||||
|
[{:keys [db] :as cofx}]
|
||||||
|
(let [{:keys [address]} (fetch-current db)]
|
||||||
|
(fx/merge
|
||||||
|
cofx
|
||||||
|
{:mailserver/update-mailservers [[address] #(re-frame/dispatch [::request-messages])]})))
|
||||||
|
|
||||||
|
(fx/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)}))
|
||||||
|
|
||||||
|
(fx/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 %)}]})
|
||||||
|
|
||||||
|
(fx/defn update-use-mailservers
|
||||||
|
{:events [:mailserver.ui/use-history-switch-pressed]}
|
||||||
|
[cofx use-mailservers?]
|
||||||
|
(fx/merge cofx
|
||||||
|
(multiaccounts.update/optimistic :use-mailservers? use-mailservers?)
|
||||||
|
(toggle-use-mailservers use-mailservers?)
|
||||||
|
(when use-mailservers?
|
||||||
|
(disconnect-from-mailserver))))
|
||||||
|
|
||||||
(fx/defn retry-next-messages-request
|
(fx/defn retry-next-messages-request
|
||||||
{:events [:mailserver.ui/retry-request-pressed]}
|
{:events [:mailserver.ui/retry-request-pressed]}
|
||||||
@ -381,15 +178,6 @@
|
|||||||
{:db (dissoc db :mailserver/request-error)}
|
{:db (dissoc db :mailserver/request-error)}
|
||||||
(process-next-messages-request)))
|
(process-next-messages-request)))
|
||||||
|
|
||||||
;; At some point we should update `last-request`, as eventually we want to move
|
|
||||||
;; on, rather then keep asking for the same data, say after n amounts of attempts
|
|
||||||
(fx/defn handle-request-error
|
|
||||||
[{:keys [db]} error]
|
|
||||||
{:db (-> db
|
|
||||||
(assoc :mailserver/request-error error)
|
|
||||||
(dissoc :mailserver/current-request
|
|
||||||
:mailserver/pending-requests))})
|
|
||||||
|
|
||||||
(fx/defn show-request-error-popup
|
(fx/defn show-request-error-popup
|
||||||
{:events [:mailserver.ui/request-error-pressed]}
|
{:events [:mailserver.ui/request-error-pressed]}
|
||||||
[{:keys [db]}]
|
[{:keys [db]}]
|
||||||
@ -401,13 +189,6 @@
|
|||||||
:on-accept #(re-frame/dispatch [:mailserver.ui/retry-request-pressed])
|
:on-accept #(re-frame/dispatch [:mailserver.ui/retry-request-pressed])
|
||||||
:confirm-button-text (i18n/label :t/mailserver-request-retry)}}))
|
:confirm-button-text (i18n/label :t/mailserver-request-retry)}}))
|
||||||
|
|
||||||
(fx/defn initialize-mailserver
|
|
||||||
[{:keys [db] :as cofx}]
|
|
||||||
(fx/merge cofx
|
|
||||||
{:db db}
|
|
||||||
(set-current-mailserver)
|
|
||||||
(process-next-messages-request)))
|
|
||||||
|
|
||||||
(def enode-address-regex
|
(def enode-address-regex
|
||||||
#"enode://[a-zA-Z0-9]+\@\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b:(\d{1,5})")
|
#"enode://[a-zA-Z0-9]+\@\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b:(\d{1,5})")
|
||||||
(def enode-url-regex
|
(def enode-url-regex
|
||||||
@ -448,7 +229,7 @@
|
|||||||
(cond-> {:address (if (seq response)
|
(cond-> {:address (if (seq response)
|
||||||
(str "enode://" enode "@" url)
|
(str "enode://" enode "@" url)
|
||||||
address)
|
address)
|
||||||
:user-defined true}
|
:custom true}
|
||||||
password (assoc :password password))))
|
password (assoc :password password))))
|
||||||
|
|
||||||
(defn- build [id mailserver-name address]
|
(defn- build [id mailserver-name address]
|
||||||
@ -456,10 +237,10 @@
|
|||||||
:id id
|
:id id
|
||||||
:name mailserver-name))
|
:name mailserver-name))
|
||||||
|
|
||||||
(def default? (comp not :user-defined fetch))
|
(def default? (comp not :custom fetch))
|
||||||
|
|
||||||
(fx/defn edit
|
(fx/defn edit
|
||||||
{:events [:mailserver.ui/user-defined-mailserver-selected]}
|
{:events [:mailserver.ui/custom-mailserver-selected]}
|
||||||
[{:keys [db] :as cofx} id]
|
[{:keys [db] :as cofx} id]
|
||||||
(let [{:keys [id address password name]} (fetch db id)
|
(let [{:keys [id address password name]} (fetch db id)
|
||||||
url (when address (build-url address password))]
|
url (when address (build-url address password))]
|
||||||
@ -568,37 +349,35 @@
|
|||||||
[{:keys [db]} new-state]
|
[{:keys [db]} new-state]
|
||||||
{:db (assoc db :mailserver/connection-error-dismissed new-state)})
|
{:db (assoc db :mailserver/connection-error-dismissed new-state)})
|
||||||
|
|
||||||
(fx/defn save-settings
|
(fx/defn pin-mailserver
|
||||||
{:events [:mailserver.ui/connect-confirmed]}
|
{:events [:mailserver.ui/connect-confirmed]}
|
||||||
[{:keys [db] :as cofx} current-fleet mailserver-id]
|
[{:keys [db] :as cofx} current-fleet mailserver-id]
|
||||||
(let [{:keys [address]} (fetch-current db)
|
(let [pinned-mailservers (-> db
|
||||||
pinned-mailservers (get-in db [:multiaccount :pinned-mailservers])
|
(get-in [:multiaccount :pinned-mailservers])
|
||||||
;; Check if previous mailserver was pinned
|
(assoc current-fleet mailserver-id))]
|
||||||
pinned? (get pinned-mailservers current-fleet)
|
|
||||||
use-mailservers? (fetch-use-mailservers? cofx)]
|
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
{:db (assoc db :mailserver/current-id mailserver-id)
|
{:db (assoc db :mailserver/current-id mailserver-id)
|
||||||
:mailserver/remove-peer address}
|
::json-rpc/call [{:method "wakuext_setPinnedMailservers"
|
||||||
(when use-mailservers? (connect-to-mailserver))
|
:params [pinned-mailservers]
|
||||||
(dismiss-connection-error false)
|
:on-success #(log/info "successfully pinned mailserver")
|
||||||
(when pinned?
|
:on-error #(log/error "failed to pin mailserver" %)}]}
|
||||||
(multiaccounts.update/multiaccount-update
|
(multiaccounts.update/optimistic :pinned-mailservers pinned-mailservers))))
|
||||||
:pinned-mailservers (assoc pinned-mailservers
|
|
||||||
current-fleet
|
|
||||||
mailserver-id)
|
|
||||||
{})))))
|
|
||||||
|
|
||||||
(fx/defn unpin
|
(fx/defn unpin
|
||||||
{:events [:mailserver.ui/unpin-pressed]}
|
{:events [:mailserver.ui/unpin-pressed]}
|
||||||
[{:keys [db] :as cofx}]
|
[{:keys [db] :as cofx}]
|
||||||
(let [current-fleet (node/current-fleet-key db)
|
(let [current-fleet (node/current-fleet-key db)
|
||||||
pinned-mailservers (get-in db [:multiaccount :pinned-mailservers])]
|
pinned-mailservers (-> db
|
||||||
|
(get-in [:multiaccount :pinned-mailservers])
|
||||||
|
(dissoc current-fleet))]
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
(multiaccounts.update/multiaccount-update
|
{::json-rpc/call [{:method "wakuext_setPinnedMailservers"
|
||||||
:pinned-mailservers (dissoc pinned-mailservers current-fleet)
|
:params [pinned-mailservers]
|
||||||
{})
|
:on-success #(log/info "successfully unpinned mailserver")
|
||||||
(dismiss-connection-error false)
|
:on-error #(log/error "failed to unpin mailserver" %)}]}
|
||||||
(change-mailserver))))
|
(multiaccounts.update/optimistic
|
||||||
|
:pinned-mailservers pinned-mailservers)
|
||||||
|
(dismiss-connection-error false))))
|
||||||
|
|
||||||
(fx/defn pin
|
(fx/defn pin
|
||||||
{:events [:mailserver.ui/pin-pressed]}
|
{:events [:mailserver.ui/pin-pressed]}
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
[status-im.i18n.i18n :as i18n]
|
[status-im.i18n.i18n :as i18n]
|
||||||
[status-im.init.core :as init]
|
[status-im.init.core :as init]
|
||||||
[status-im.native-module.core :as status]
|
[status-im.native-module.core :as status]
|
||||||
[status-im.transport.core :as transport]
|
|
||||||
[status-im.utils.fx :as fx]
|
[status-im.utils.fx :as fx]
|
||||||
[status-im.multiaccounts.core :as multiaccounts]
|
[status-im.multiaccounts.core :as multiaccounts]
|
||||||
[status-im.utils.keychain.core :as keychain]
|
[status-im.utils.keychain.core :as keychain]
|
||||||
@ -26,7 +25,6 @@
|
|||||||
(when should-send-metrics?
|
(when should-send-metrics?
|
||||||
(anon-metrics/stop-transferring))
|
(anon-metrics/stop-transferring))
|
||||||
(keychain/save-auth-method key-uid auth-method)
|
(keychain/save-auth-method key-uid auth-method)
|
||||||
(transport/stop-whisper)
|
|
||||||
(wallet/clear-timeouts)
|
(wallet/clear-timeouts)
|
||||||
(init/initialize-app-db))))
|
(init/initialize-app-db))))
|
||||||
|
|
||||||
|
@ -42,7 +42,6 @@
|
|||||||
{:db (assoc db
|
{:db (assoc db
|
||||||
:peers-summary peers-summary
|
:peers-summary peers-summary
|
||||||
:peers-count peers-count)}
|
:peers-count peers-count)}
|
||||||
(mailserver/peers-summary-change previous-summary)
|
|
||||||
(visibility-status-updates/peers-summary-change peers-count))))
|
(visibility-status-updates/peers-summary-change peers-count))))
|
||||||
|
|
||||||
(fx/defn wakuv2-peer-stats
|
(fx/defn wakuv2-peer-stats
|
||||||
@ -67,6 +66,9 @@
|
|||||||
"envelope.expired" (transport.message/update-envelopes-status cofx (:ids (js->clj event-js :keywordize-keys true)) :not-sent)
|
"envelope.expired" (transport.message/update-envelopes-status cofx (:ids (js->clj event-js :keywordize-keys true)) :not-sent)
|
||||||
"message.delivered" (let [{:keys [chatID messageID]} (js->clj event-js :keywordize-keys true)]
|
"message.delivered" (let [{:keys [chatID messageID]} (js->clj event-js :keywordize-keys true)]
|
||||||
(models.message/update-db-message-status cofx chatID messageID :delivered))
|
(models.message/update-db-message-status cofx chatID messageID :delivered))
|
||||||
|
"mailserver.changed" (mailserver/handle-mailserver-changed cofx (.-id event-js))
|
||||||
|
"mailserver.available" (mailserver/handle-mailserver-available cofx (.-id event-js))
|
||||||
|
"mailserver.not.working" (mailserver/handle-mailserver-not-working cofx)
|
||||||
"discovery.summary" (summary cofx (js->clj event-js :keywordize-keys true))
|
"discovery.summary" (summary cofx (js->clj event-js :keywordize-keys true))
|
||||||
"wakuv2.peerstats" (wakuv2-peer-stats cofx (js->clj event-js :keywordize-keys true))
|
"wakuv2.peerstats" (wakuv2-peer-stats cofx (js->clj event-js :keywordize-keys true))
|
||||||
"subscriptions.data" (ethereum.subscriptions/handle-signal cofx (js->clj event-js :keywordize-keys true))
|
"subscriptions.data" (ethereum.subscriptions/handle-signal cofx (js->clj event-js :keywordize-keys true))
|
||||||
|
@ -2,12 +2,10 @@
|
|||||||
status-im.transport.core
|
status-im.transport.core
|
||||||
(:require [re-frame.core :as re-frame]
|
(:require [re-frame.core :as re-frame]
|
||||||
[status-im.ethereum.json-rpc :as json-rpc]
|
[status-im.ethereum.json-rpc :as json-rpc]
|
||||||
[status-im.mailserver.core :as mailserver]
|
|
||||||
[status-im.native-module.core :as status]
|
[status-im.native-module.core :as status]
|
||||||
[status-im.pairing.core :as pairing]
|
[status-im.pairing.core :as pairing]
|
||||||
[status-im.utils.fx :as fx]
|
[status-im.utils.fx :as fx]
|
||||||
[status-im.utils.handlers :as handlers]
|
[status-im.utils.handlers :as handlers]
|
||||||
[status-im.utils.publisher :as publisher]
|
|
||||||
status-im.transport.shh
|
status-im.transport.shh
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[status-im.utils.universal-links.core :as universal-links]))
|
[status-im.utils.universal-links.core :as universal-links]))
|
||||||
@ -34,19 +32,19 @@
|
|||||||
(fx/defn fetch-node-info-fx [cofx]
|
(fx/defn fetch-node-info-fx [cofx]
|
||||||
{::fetch-node-info []})
|
{::fetch-node-info []})
|
||||||
|
|
||||||
(defn add-custom-mailservers
|
(defn add-mailservers
|
||||||
[db custom-mailservers]
|
[db mailservers]
|
||||||
(reduce (fn [db {:keys [fleet] :as mailserver}]
|
(reduce (fn [db {:keys [fleet id name] :as mailserver}]
|
||||||
(let [{:keys [id] :as mailserver}
|
(let [updated-mailserver
|
||||||
(-> mailserver
|
(-> mailserver
|
||||||
(update :id keyword)
|
(update :id keyword)
|
||||||
(dissoc :fleet)
|
(assoc :name (if (seq name) name id))
|
||||||
(assoc :user-defined true))]
|
(dissoc :fleet))]
|
||||||
(assoc-in db
|
(assoc-in db
|
||||||
[:mailserver/mailservers (keyword fleet) id]
|
[:mailserver/mailservers (keyword fleet) (keyword id)]
|
||||||
mailserver)))
|
updated-mailserver)))
|
||||||
db
|
db
|
||||||
custom-mailservers))
|
mailservers))
|
||||||
|
|
||||||
(fx/defn start-messenger
|
(fx/defn start-messenger
|
||||||
"We should only start receiving messages/processing topics once all the
|
"We should only start receiving messages/processing topics once all the
|
||||||
@ -64,14 +62,7 @@
|
|||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
{:db (-> db
|
{:db (-> db
|
||||||
(assoc :messenger/started? true)
|
(assoc :messenger/started? true)
|
||||||
(add-custom-mailservers mailservers))}
|
(add-mailservers mailservers))}
|
||||||
(fetch-node-info-fx)
|
(fetch-node-info-fx)
|
||||||
(pairing/init)
|
(pairing/init)
|
||||||
(publisher/start-fx)
|
|
||||||
(mailserver/initialize-mailserver)
|
|
||||||
(universal-links/process-stored-event)))
|
(universal-links/process-stored-event)))
|
||||||
|
|
||||||
(fx/defn stop-whisper
|
|
||||||
"Stops whisper protocol"
|
|
||||||
[cofx]
|
|
||||||
(publisher/stop-fx cofx))
|
|
||||||
|
@ -155,7 +155,9 @@
|
|||||||
(i18n/label :t/status-mobile-descr)]])]))
|
(i18n/label :t/status-mobile-descr)]])]))
|
||||||
|
|
||||||
(defn get-icon [{:keys [peers node mobile sync]}]
|
(defn get-icon [{:keys [peers node mobile sync]}]
|
||||||
(if (= peers :offline)
|
(if (or (= peers :offline)
|
||||||
|
(= node :offline)
|
||||||
|
(= node :connecting))
|
||||||
:main-icons/offline
|
:main-icons/offline
|
||||||
(if mobile
|
(if mobile
|
||||||
(if sync :main-icons/mobile-sync :main-icons/mobile-sync-off)
|
(if sync :main-icons/mobile-sync :main-icons/mobile-sync-off)
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
[react/text {:style styles/explanation-text}
|
[react/text {:style styles/explanation-text}
|
||||||
(i18n/label :t/mailserver-automatic-switch-explanation)]]])
|
(i18n/label :t/mailserver-automatic-switch-explanation)]]])
|
||||||
|
|
||||||
(defn render-row [{:keys [name id user-defined]} _ _ {:keys [current-mailserver-id preferred-mailserver-id]}]
|
(defn render-row [{:keys [name id custom]} _ _ {:keys [current-mailserver-id preferred-mailserver-id]}]
|
||||||
(let [pinned? preferred-mailserver-id
|
(let [pinned? preferred-mailserver-id
|
||||||
connected? (= id current-mailserver-id)
|
connected? (= id current-mailserver-id)
|
||||||
visible? (or pinned? ; show everything when auto selection is turned off
|
visible? (or pinned? ; show everything when auto selection is turned off
|
||||||
@ -33,8 +33,8 @@
|
|||||||
|
|
||||||
(when visible?
|
(when visible?
|
||||||
[react/touchable-highlight
|
[react/touchable-highlight
|
||||||
{:on-press (when pinned? #(if user-defined
|
{:on-press (when pinned? #(if custom
|
||||||
(re-frame/dispatch [:mailserver.ui/user-defined-mailserver-selected id])
|
(re-frame/dispatch [:mailserver.ui/custom-mailserver-selected id])
|
||||||
(re-frame/dispatch [:mailserver.ui/default-mailserver-selected id])))
|
(re-frame/dispatch [:mailserver.ui/default-mailserver-selected id])))
|
||||||
:accessibility-label :mailserver-item}
|
:accessibility-label :mailserver-item}
|
||||||
[react/view (styles/mailserver-item)
|
[react/view (styles/mailserver-item)
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
(ns status-im.utils.publisher
|
|
||||||
(:require [re-frame.core :as re-frame]
|
|
||||||
[re-frame.db]
|
|
||||||
[status-im.utils.async :as async-util]
|
|
||||||
[status-im.mailserver.core :as mailserver]
|
|
||||||
[status-im.utils.fx :as fx]))
|
|
||||||
|
|
||||||
(defonce polling-executor (atom nil))
|
|
||||||
(def sync-interval-ms 10000)
|
|
||||||
(def sync-timeout-ms 20000)
|
|
||||||
|
|
||||||
(defn- start-publisher! []
|
|
||||||
(when @polling-executor
|
|
||||||
(async-util/async-periodic-stop! @polling-executor))
|
|
||||||
(reset! polling-executor
|
|
||||||
(async-util/async-periodic-exec
|
|
||||||
(fn [done-fn]
|
|
||||||
(mailserver/check-connection!)
|
|
||||||
(done-fn))
|
|
||||||
sync-interval-ms
|
|
||||||
sync-timeout-ms)))
|
|
||||||
|
|
||||||
(re-frame/reg-fx
|
|
||||||
::start-publisher
|
|
||||||
start-publisher!)
|
|
||||||
|
|
||||||
(re-frame/reg-fx
|
|
||||||
::stop-publisher
|
|
||||||
#(when @polling-executor
|
|
||||||
(async-util/async-periodic-stop! @polling-executor)))
|
|
||||||
|
|
||||||
(fx/defn start-fx
|
|
||||||
[_]
|
|
||||||
{::start-publisher nil})
|
|
||||||
|
|
||||||
(fx/defn stop-fx
|
|
||||||
[_]
|
|
||||||
{::stop-publisher []})
|
|
@ -3,7 +3,7 @@
|
|||||||
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
||||||
"owner": "status-im",
|
"owner": "status-im",
|
||||||
"repo": "status-go",
|
"repo": "status-go",
|
||||||
"version": "v0.94.10",
|
"version": "v0.96.0",
|
||||||
"commit-sha1": "598b83757cc8b27e3374e50de02187eacf0d4280",
|
"commit-sha1": "d60a6713fe2a0ed0fdf03a0777a8cfa7391d7c56",
|
||||||
"src-sha256": "0ncywjmpng7zdx707j45yxzj0m06c24mi0lgk3d2yzbp7gx3cygz"
|
"src-sha256": "19jzac10xwl8hpls45ph56f4gqyydwg3rdqmvm25fmp8ggjwvr1m"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user