[#4551] fix error on fetching history for removed chat

This commit is contained in:
Roman Volosovskyi 2018-05-31 11:57:09 +03:00
parent 9058c54933
commit 5d41cdda0c
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
1 changed files with 4 additions and 1 deletions

View File

@ -371,7 +371,10 @@
(handlers/register-handler-fx
:inbox/check-fetching
(fn [{:keys [db now] :as cofx} [_ last-request chat-id]]
(when (:inbox/fetching? db)
(when (and (:inbox/fetching? db)
;; if chat was removed before messages were fetched no need
;; to proceed with further actions
(or (not chat-id) (contains? (:transport/chats db) chat-id)))
(let [time-since-last-received (- now (:inbox/last-received db))]
(if (> time-since-last-received fetching-timeout)
(if chat-id