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
1 changed files with 8 additions and 6 deletions

View File

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