Set current-chat-id to nil once chat is deleted (desktop only)
This commit is contained in:
parent
e40d06f8d9
commit
1186b73be8
|
@ -2,6 +2,7 @@
|
||||||
(:require [status-im.ui.components.styles :as styles]
|
(:require [status-im.ui.components.styles :as styles]
|
||||||
[status-im.utils.gfycat.core :as gfycat]
|
[status-im.utils.gfycat.core :as gfycat]
|
||||||
[status-im.transport.utils :as transport.utils]
|
[status-im.transport.utils :as transport.utils]
|
||||||
|
[status-im.utils.platform :as platform]
|
||||||
[status-im.utils.clocks :as utils.clocks]
|
[status-im.utils.clocks :as utils.clocks]
|
||||||
[status-im.transport.message.core :as transport.message]
|
[status-im.transport.message.core :as transport.message]
|
||||||
[status-im.data-store.chats :as chats-store]
|
[status-im.data-store.chats :as chats-store]
|
||||||
|
@ -101,9 +102,11 @@
|
||||||
(transport.utils/unsubscribe-from-chat chat-id cofx)))
|
(transport.utils/unsubscribe-from-chat chat-id cofx)))
|
||||||
|
|
||||||
(defn- deactivate-chat [chat-id {:keys [db now] :as cofx}]
|
(defn- deactivate-chat [chat-id {:keys [db now] :as cofx}]
|
||||||
(assoc-in {:db db
|
(cond-> (assoc-in {:db db
|
||||||
:data-store/tx [(chats-store/deactivate-chat-tx chat-id now)]}
|
:data-store/tx [(chats-store/deactivate-chat-tx chat-id now)]}
|
||||||
[:db :chats chat-id :is-active] false))
|
[: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)
|
;; 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
|
;; is done at the same time as the removal of the chat, so a message
|
||||||
|
|
|
@ -6,4 +6,6 @@
|
||||||
:show-desktop-tab
|
:show-desktop-tab
|
||||||
(fn [{:keys [db] :as cofx} [_ tab-name]]
|
(fn [{:keys [db] :as cofx} [_ tab-name]]
|
||||||
{:db (assoc-in db [:desktop/desktop :tab-view-id] 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)]}))
|
||||||
|
|
Loading…
Reference in New Issue