Set current-chat-id to nil once chat is deleted (desktop only)

This commit is contained in:
Vitaliy Vlasov 2018-08-01 11:27:38 -06:00
parent e40d06f8d9
commit 1186b73be8
No known key found for this signature in database
GPG Key ID: A7D57C347F2B2964
2 changed files with 9 additions and 4 deletions

View File

@ -2,6 +2,7 @@
(:require [status-im.ui.components.styles :as styles]
[status-im.utils.gfycat.core :as gfycat]
[status-im.transport.utils :as transport.utils]
[status-im.utils.platform :as platform]
[status-im.utils.clocks :as utils.clocks]
[status-im.transport.message.core :as transport.message]
[status-im.data-store.chats :as chats-store]
@ -101,9 +102,11 @@
(transport.utils/unsubscribe-from-chat chat-id cofx)))
(defn- deactivate-chat [chat-id {:keys [db now] :as cofx}]
(assoc-in {:db db
:data-store/tx [(chats-store/deactivate-chat-tx chat-id now)]}
[:db :chats chat-id :is-active] false))
(cond-> (assoc-in {:db db
:data-store/tx [(chats-store/deactivate-chat-tx chat-id now)]}
[:db :chats chat-id :is-active] false)
platform/desktop?
(assoc-in [:db :current-chat-id] nil)))
;; TODO: There's a race condition here, as the removal of the filter (async)
;; is done at the same time as the removal of the chat, so a message

View File

@ -6,4 +6,6 @@
:show-desktop-tab
(fn [{:keys [db] :as cofx} [_ tab-name]]
{:db (assoc-in db [:desktop/desktop :tab-view-id] tab-name)
:dispatch [:navigate-to (if (= tab-name :home) :chat :home)]}))
:dispatch [:navigate-to (if (and (= tab-name :home) (:current-chat-id db))
:chat
:home)]}))