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