[#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 "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 (preferred-mailserver-id cofx) (if-let [preferred-mailserver (preferred-mailserver-id cofx)]
{:db (update-mailserver-state db :error)} (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)] (let [{:keys [address]} (fetch-current cofx)]
(fx/merge cofx (fx/merge cofx
{:mailserver/remove-peer address} {:mailserver/remove-peer address}
@ -384,7 +398,7 @@
(fx/merge cofx (fx/merge cofx
{:db (dissoc db :mailserver/connection-checks)} {:db (dissoc db :mailserver/connection-checks)}
(when (= :connecting (:mailserver/state db)) (when (= :connecting (:mailserver/state db))
(change-mailserver cofx))) (change-mailserver)))
{:db (update db :mailserver/connection-checks dec)})))) {:db (update db :mailserver/connection-checks dec)}))))
(fx/defn reset-request-to (fx/defn reset-request-to

View File

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

View File

@ -901,5 +901,9 @@
"sticker-market": "Sticker market", "sticker-market": "Sticker market",
"you-dont-have-stickers": "You dont have any stickers yet", "you-dont-have-stickers": "You dont have any stickers yet",
"get-stickers": "Get Stickers", "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."
} }