diff --git a/src/status_im/events.cljs b/src/status_im/events.cljs index 530431d33c..fd8cfb076a 100644 --- a/src/status_im/events.cljs +++ b/src/status_im/events.cljs @@ -371,6 +371,11 @@ (fn [cofx [_ _ url]] (mailserver/set-url-from-qr cofx url))) +(handlers/register-handler-fx + :mailserver.callback/resend-request + (fn [cofx [_ request]] + (mailserver/resend-request cofx request))) + (handlers/register-handler-fx :mailserver.ui/connect-pressed (fn [cofx [_ mailserver-id]] diff --git a/src/status_im/mailserver/core.cljs b/src/status_im/mailserver/core.cljs index 6d4dd47c98..05066432b5 100644 --- a/src/status_im/mailserver/core.cljs +++ b/src/status_im/mailserver/core.cljs @@ -40,6 +40,7 @@ (def request-timeout 30) (def min-limit 200) (def max-limit 2000) +(def backoff-interval-ms 3000) (def default-limit max-limit) (def connection-timeout "Time after which mailserver connection is considered to have failed" @@ -290,7 +291,8 @@ (log/info "mailserver: messages request success for topic " topics "from" from "to" to) (do (log/error "mailserver: messages request error for topic " topics ": " error) - (re-frame/dispatch [:mailserver.callback/request-error (i18n/label :t/mailserver-request-error-title)]))))))) + (utils/set-timeout #(re-frame/dispatch [:mailserver.callback/resend-request {:request-id "failed-request"}]) + backoff-interval-ms))))))) (re-frame/reg-fx :mailserver/request-messages @@ -572,8 +574,9 @@ (fx/defn resend-request [{:keys [db] :as cofx} {:keys [request-id]}] - (if (<= maximum-number-of-attempts - (get-in db [:mailserver/current-request :attempts])) + (if (and (:mailserver/current-request db) + (<= maximum-number-of-attempts + (get-in db [:mailserver/current-request :attempts]))) (fx/merge cofx {:db (update db :mailserver/current-request dissoc :attempts)} (change-mailserver))