mirror of
https://github.com/status-im/status-react.git
synced 2025-01-09 18:46:19 +00:00
Dont change mailserver if no network
When we are offline, we don't try to change mailserver, and we don't show a pop up to the user, as it is not that the mailserver is not working, we are just offline. Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
parent
8a2b7fc0dc
commit
229f5ae108
@ -383,27 +383,28 @@
|
|||||||
"mark mailserver status as `:error` if custom mailserver is used
|
"mark mailserver status as `:error` if custom mailserver is used
|
||||||
otherwise try to reconnect to another mailserver"
|
otherwise try to reconnect to another mailserver"
|
||||||
[{:keys [db] :as cofx}]
|
[{:keys [db] :as cofx}]
|
||||||
(if-let [preferred-mailserver (preferred-mailserver-id cofx)]
|
(when-not (zero? (:peers-count db))
|
||||||
(let [current-fleet (fleet/current-fleet db)]
|
(if-let [preferred-mailserver (preferred-mailserver-id cofx)]
|
||||||
{:db
|
(let [current-fleet (fleet/current-fleet db)]
|
||||||
(update-mailserver-state db :error)
|
{:db
|
||||||
:ui/show-confirmation
|
(update-mailserver-state db :error)
|
||||||
{:title (i18n/label :t/mailserver-error-title)
|
:ui/show-confirmation
|
||||||
:content (i18n/label :t/mailserver-error-content)
|
{:title (i18n/label :t/mailserver-error-title)
|
||||||
:confirm-button-text (i18n/label :t/mailserver-pick-another)
|
:content (i18n/label :t/mailserver-error-content)
|
||||||
:on-accept #(re-frame/dispatch
|
:confirm-button-text (i18n/label :t/mailserver-pick-another)
|
||||||
[:navigate-to :offline-messaging-settings])
|
:on-accept #(re-frame/dispatch
|
||||||
:extra-options [{:text (i18n/label :t/mailserver-retry)
|
[:navigate-to :offline-messaging-settings])
|
||||||
:onPress #(re-frame/dispatch
|
:extra-options [{:text (i18n/label :t/mailserver-retry)
|
||||||
[:mailserver.ui/connect-confirmed
|
:onPress #(re-frame/dispatch
|
||||||
current-fleet
|
[:mailserver.ui/connect-confirmed
|
||||||
preferred-mailserver])
|
current-fleet
|
||||||
:style "default"}]}})
|
preferred-mailserver])
|
||||||
(let [{:keys [address]} (fetch-current cofx)]
|
:style "default"}]}})
|
||||||
(fx/merge cofx
|
(let [{:keys [address]} (fetch-current cofx)]
|
||||||
{:mailserver/remove-peer address}
|
(fx/merge cofx
|
||||||
(set-current-mailserver)
|
{:mailserver/remove-peer address}
|
||||||
(connect-to-mailserver)))))
|
(set-current-mailserver)
|
||||||
|
(connect-to-mailserver))))))
|
||||||
|
|
||||||
(fx/defn check-connection
|
(fx/defn check-connection
|
||||||
"connection-checks counter is used to prevent changing
|
"connection-checks counter is used to prevent changing
|
||||||
|
@ -28,6 +28,32 @@
|
|||||||
:enode "enode://0f7c65277f916ff4379fe520b875082a56e587eb3ce1c1567d9ff94206bdb05ba167c52272f20f634cd1ebdec5d9dfeb393018bfde1595d8e64a717c8b46692f@203.136.241.111:40404"
|
:enode "enode://0f7c65277f916ff4379fe520b875082a56e587eb3ce1c1567d9ff94206bdb05ba167c52272f20f634cd1ebdec5d9dfeb393018bfde1595d8e64a717c8b46692f@203.136.241.111:40404"
|
||||||
:name "Geth/v1.7.2-stable/linux-amd64/go1.9.1"}])
|
:name "Geth/v1.7.2-stable/linux-amd64/go1.9.1"}])
|
||||||
|
|
||||||
|
(deftest change-mailserver
|
||||||
|
(testing "we are offline"
|
||||||
|
(testing "it does not change mailserver"
|
||||||
|
(is (not (mailserver/change-mailserver {:db {:peers-count 0}})))))
|
||||||
|
(testing "we are online"
|
||||||
|
(testing "there's a preferred mailserver"
|
||||||
|
(testing "it shows the popup"
|
||||||
|
(is (:ui/show-confirmation (mailserver/change-mailserver
|
||||||
|
{:db {:account/account {:settings
|
||||||
|
{:fleet :beta
|
||||||
|
:mailserver {:beta "id"}}}
|
||||||
|
:peers-count 1}})))))
|
||||||
|
(testing "there's not a preferred mailserver"
|
||||||
|
(testing "it changes the mailserver"
|
||||||
|
(is (= :a
|
||||||
|
(get-in
|
||||||
|
(mailserver/change-mailserver
|
||||||
|
{:db {:mailserver/mailservers {:beta {:a "b"}}
|
||||||
|
:account/account {:settings
|
||||||
|
{:fleet :beta}}
|
||||||
|
:peers-count 1}})
|
||||||
|
[:db :mailserver/current-id]))))
|
||||||
|
(testing "it does not show the popup"
|
||||||
|
(is (not (:ui/show-confirmation (mailserver/change-mailserver
|
||||||
|
{:db {:peers-count 1}}))))))))
|
||||||
|
|
||||||
(deftest test-registered-peer?
|
(deftest test-registered-peer?
|
||||||
(testing "Peer is registered"
|
(testing "Peer is registered"
|
||||||
(is (mailserver/registered-peer? peers enode)))
|
(is (mailserver/registered-peer? peers enode)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user