Do not update :mailserver/connection-checks` if the user is logged out.

Connection check should be skipped if the user has logged out, otherwise
`app-db` may end up in an invalid state which causes an error and red screen
in dev mode.
This commit is contained in:
Roman Volosovskyi 2018-12-08 17:34:30 +02:00
parent c810e0f2c3
commit e20af4d206
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE

View File

@ -364,12 +364,14 @@
else else
change mailserver if mailserver is connected" change mailserver if mailserver is connected"
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(if (zero? (dec (:mailserver/connection-checks db))) ;; check if logged into account
(fx/merge cofx (when (contains? db :account/account)
{:db (dissoc db :mailserver/connection-checks)} (if (zero? (dec (:mailserver/connection-checks db)))
(when (= :connecting (:mailserver/state db)) (fx/merge cofx
(change-mailserver cofx))) {:db (dissoc db :mailserver/connection-checks)}
{:db (update db :mailserver/connection-checks dec)})) (when (= :connecting (:mailserver/state db))
(change-mailserver cofx)))
{:db (update db :mailserver/connection-checks dec)})))
(fx/defn reset-request-to (fx/defn reset-request-to
[{:keys [db]}] [{:keys [db]}]