Close chat when pop-to-root is called (#20238)
This commit is contained in:
parent
f25584d833
commit
2ff8850c62
|
@ -311,7 +311,7 @@
|
|||
{:browser-id (:browser-id browser)}
|
||||
:browser/screen-id :browser)}
|
||||
(navigation/pop-to-root :shell-stack)
|
||||
(chat.events/close-chat)
|
||||
(chat.events/close-chat (:current-chat-id db))
|
||||
(navigation/change-tab :browser-stack)
|
||||
(update-browser browser)
|
||||
(resolve-url nil))
|
||||
|
|
|
@ -144,19 +144,21 @@
|
|||
|
||||
(rf/defn close-chat
|
||||
{:events [:chat/close]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(when-let [chat-id (:current-chat-id db)]
|
||||
(chat.state/reset-visible-item)
|
||||
(rf/merge cofx
|
||||
{:db (-> db
|
||||
(dissoc :current-chat-id)
|
||||
(assoc-in [:chat/inputs chat-id :focused?] false))
|
||||
:effects.async-storage/set {:chat-id nil
|
||||
:key-uid nil}}
|
||||
(link-preview/reset-all)
|
||||
(delete-for-me/sync-all)
|
||||
(delete-message/send-all)
|
||||
(offload-messages chat-id))))
|
||||
[{:keys [db] :as cofx} chat-id]
|
||||
(let [current-chat-id (:current-chat-id db)
|
||||
chat-id (or chat-id current-chat-id)]
|
||||
(when (and current-chat-id (= chat-id current-chat-id))
|
||||
(chat.state/reset-visible-item)
|
||||
(rf/merge cofx
|
||||
{:db (-> db
|
||||
(dissoc :current-chat-id)
|
||||
(assoc-in [:chat/inputs chat-id :focused?] false))
|
||||
:effects.async-storage/set {:chat-id nil
|
||||
:key-uid nil}}
|
||||
(link-preview/reset-all)
|
||||
(delete-for-me/sync-all)
|
||||
(delete-message/send-all)
|
||||
(offload-messages chat-id)))))
|
||||
|
||||
(rf/defn deactivate-chat
|
||||
"Deactivate chat in db, no side effects"
|
||||
|
@ -173,7 +175,7 @@
|
|||
:on-error #(log/error "failed to create public chat" chat-id %)}]}
|
||||
(clear-history chat-id true)
|
||||
(when (= chat-id (:current-chat-id db))
|
||||
(close-chat))))
|
||||
(close-chat chat-id))))
|
||||
|
||||
(rf/defn force-close-chat
|
||||
[{:keys [db] :as cofx} chat-id]
|
||||
|
@ -201,7 +203,7 @@
|
|||
[{db :db :as cofx} chat-id animation]
|
||||
(rf/merge cofx
|
||||
{:dispatch [(if animation :shell/navigate-to :navigate-to) :chat chat-id animation]}
|
||||
(close-chat)
|
||||
(close-chat chat-id)
|
||||
(force-close-chat chat-id)
|
||||
(fn [{:keys [db]}]
|
||||
{:db (assoc db :current-chat-id chat-id)})
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
[status-im.contexts.shell.jump-to.events :as shell.events]
|
||||
[status-im.contexts.shell.jump-to.state :as shell.state]
|
||||
[status-im.contexts.shell.jump-to.utils :as shell.utils]
|
||||
[status-im.feature-flags :as ff]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn- all-screens-params
|
||||
|
@ -57,12 +58,16 @@
|
|||
(rf/defn pop-to-root
|
||||
{:events [:pop-to-root]}
|
||||
[{:keys [db]} tab]
|
||||
{:pop-to-root-fx tab
|
||||
:db (-> db
|
||||
(dissoc :shell/floating-screens)
|
||||
(dissoc :shell/loaded-screens)
|
||||
(assoc :view-id (or @shell.state/selected-stack-id :shell)))
|
||||
:effects.shell/pop-to-root nil})
|
||||
(cond->
|
||||
{:pop-to-root-fx tab
|
||||
:db (-> db
|
||||
(dissoc :shell/floating-screens)
|
||||
(dissoc :shell/loaded-screens)
|
||||
(assoc :view-id (or @shell.state/selected-stack-id :shell)))
|
||||
:effects.shell/pop-to-root nil}
|
||||
|
||||
(and (:current-chat-id db) (not (ff/enabled? ::ff/shell.jump-to)))
|
||||
(assoc :dispatch [:chat/close (:current-chat-id db)])))
|
||||
|
||||
(rf/defn init-root
|
||||
{:events [:init-root]}
|
||||
|
|
Loading…
Reference in New Issue