[#7422] Show feedback on mailserver error

This commit is contained in:
Roman Volosovskyi 2019-02-05 14:04:06 +02:00
parent 5fe9e3d156
commit b96063ce56
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
3 changed files with 34 additions and 13 deletions

View File

@ -361,8 +361,22 @@
"mark mailserver status as `:error` if custom mailserver is used
otherwise try to reconnect to another mailserver"
[{:keys [db] :as cofx}]
(if (preferred-mailserver-id cofx)
{:db (update-mailserver-state db :error)}
(if-let [preferred-mailserver (preferred-mailserver-id cofx)]
(let [current-fleet (fleet/current-fleet db)]
{:db
(update-mailserver-state db :error)
: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-accept #(re-frame/dispatch
[:navigate-to :offline-messaging-settings])
:extra-options [{:text (i18n/label :t/mailserver-retry)
:onPress #(re-frame/dispatch
[:mailserver.ui/connect-confirmed
current-fleet
preferred-mailserver])
:style "default"}]}})
(let [{:keys [address]} (fetch-current cofx)]
(fx/merge cofx
{:mailserver/remove-peer address}
@ -384,7 +398,7 @@
(fx/merge cofx
{:db (dissoc db :mailserver/connection-checks)}
(when (= :connecting (:mailserver/state db))
(change-mailserver cofx)))
(change-mailserver)))
{:db (update db :mailserver/connection-checks dec)}))))
(fx/defn reset-request-to

View File

@ -24,12 +24,14 @@
(show-popup title content on-dismiss)))
(defn show-confirmation
[{:keys [title content confirm-button-text on-dismiss on-accept on-cancel cancel-button-text]}]
[{:keys [title content confirm-button-text on-dismiss on-accept on-cancel cancel-button-text
extra-options]}]
(.alert (.-Alert rn-dependencies/react-native)
title
content
;; Styles are only relevant on iOS. On Android first button is 'neutral' and second is 'positive'
(clj->js
(concat
(vector (merge {:text (or cancel-button-text (i18n/label :t/cancel))
:style "cancel"
:accessibility-label :cancel-button}
@ -37,7 +39,8 @@
{:text (or confirm-button-text (i18n/label :t/ok))
:onPress on-accept
:style "default"
:accessibility-label :confirm-button}))
:accessibility-label :confirm-button})
(or extra-options nil)))
#js {:cancelable false}))
(re-frame/reg-fx

View File

@ -901,5 +901,9 @@
"sticker-market": "Sticker market",
"you-dont-have-stickers": "You dont have any stickers yet",
"get-stickers": "Get Stickers",
"recently-used-stickers": "Recently used stickers will appear here"
"recently-used-stickers": "Recently used stickers will appear here",
"mailserver-retry": "Retry",
"mailserver-pick-another": "Pick another mailserver",
"mailserver-error-title": "Error connecting to mailserver",
"mailserver-error-content": "The mailserver you selected couldn't be reached."
}