mirror of
https://github.com/status-im/status-mobile.git
synced 2025-01-27 08:55:39 +00:00
Improve switcher cards lifecycle (#14751)
This commit is contained in:
parent
220341e0be
commit
5c0bd33697
@ -54,11 +54,13 @@
|
|||||||
;; Helper functions
|
;; Helper functions
|
||||||
(defn get-shared-value
|
(defn get-shared-value
|
||||||
[anim]
|
[anim]
|
||||||
(.-value anim))
|
(when anim
|
||||||
|
(.-value anim)))
|
||||||
|
|
||||||
(defn set-shared-value
|
(defn set-shared-value
|
||||||
[anim val]
|
[anim val]
|
||||||
(set! (.-value anim) val))
|
(when anim
|
||||||
|
(set! (.-value anim) val)))
|
||||||
|
|
||||||
(defn kebab-case->camelCase
|
(defn kebab-case->camelCase
|
||||||
[k]
|
[k]
|
||||||
|
@ -220,11 +220,17 @@
|
|||||||
|
|
||||||
(rf/defn close-chat
|
(rf/defn close-chat
|
||||||
{:events [:close-chat]}
|
{:events [:close-chat]}
|
||||||
[{:keys [db] :as cofx}]
|
[{:keys [db] :as cofx} navigate-to-shell?]
|
||||||
(when-let [chat-id (:current-chat-id db)]
|
(when-let [chat-id (:current-chat-id db)]
|
||||||
(chat.state/reset-visible-item)
|
(chat.state/reset-visible-item)
|
||||||
(rf/merge cofx
|
(rf/merge cofx
|
||||||
{:db (dissoc db :current-chat-id)}
|
(merge
|
||||||
|
{:db (dissoc db :current-chat-id)}
|
||||||
|
(let [community-id (get-in db [:chats chat-id :community-id])]
|
||||||
|
;; When navigating back from community chat to community, update switcher card
|
||||||
|
(when (and community-id (not navigate-to-shell?))
|
||||||
|
{:dispatch [:shell/add-switcher-card
|
||||||
|
:community {:community-id community-id}]})))
|
||||||
(delete-for-me/sync-all)
|
(delete-for-me/sync-all)
|
||||||
(delete-message/send-all)
|
(delete-message/send-all)
|
||||||
(offload-messages chat-id))))
|
(offload-messages chat-id))))
|
||||||
@ -243,7 +249,8 @@
|
|||||||
[{:keys [db now] :as cofx} chat-id]
|
[{:keys [db now] :as cofx} chat-id]
|
||||||
(rf/merge cofx
|
(rf/merge cofx
|
||||||
{:clear-message-notifications
|
{:clear-message-notifications
|
||||||
[[chat-id] (get-in db [:multiaccount :remote-push-notifications-enabled?])]}
|
[[chat-id] (get-in db [:multiaccount :remote-push-notifications-enabled?])]
|
||||||
|
:dispatch [:shell/close-switcher-card chat-id]}
|
||||||
(deactivate-chat chat-id)
|
(deactivate-chat chat-id)
|
||||||
(offload-messages chat-id)))
|
(offload-messages chat-id)))
|
||||||
|
|
||||||
@ -268,7 +275,7 @@
|
|||||||
(navigation/change-tab :chat)
|
(navigation/change-tab :chat)
|
||||||
(when-not (= (:view-id db) :community)
|
(when-not (= (:view-id db) :community)
|
||||||
(navigation/pop-to-root-tab :chat-stack))
|
(navigation/pop-to-root-tab :chat-stack))
|
||||||
(close-chat)
|
(close-chat false)
|
||||||
(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)})
|
||||||
@ -284,7 +291,7 @@
|
|||||||
{:dispatch [:navigate-to-nav2 :chat chat-id from-shell?]}
|
{:dispatch [:navigate-to-nav2 :chat chat-id from-shell?]}
|
||||||
(when-not (= (:view-id db) :community)
|
(when-not (= (:view-id db) :community)
|
||||||
(navigation/pop-to-root-tab :shell-stack))
|
(navigation/pop-to-root-tab :shell-stack))
|
||||||
(close-chat)
|
(close-chat false)
|
||||||
(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)})
|
||||||
@ -311,7 +318,7 @@
|
|||||||
(assoc-in [:chats chat-id] chat)
|
(assoc-in [:chats chat-id] chat)
|
||||||
:always
|
:always
|
||||||
(update :chats-home-list conj chat-id))
|
(update :chats-home-list conj chat-id))
|
||||||
:dispatch [:chat.ui/navigate-to-chat chat-id]}))
|
:dispatch [:chat.ui/navigate-to-chat-nav2 chat-id]}))
|
||||||
|
|
||||||
(rf/defn navigate-to-user-pinned-messages
|
(rf/defn navigate-to-user-pinned-messages
|
||||||
"Takes coeffects map and chat-id, returns effects necessary for navigation and preloading data"
|
"Takes coeffects map and chat-id, returns effects necessary for navigation and preloading data"
|
||||||
|
@ -187,6 +187,7 @@
|
|||||||
(keys (get-in db [:communities community-id :chats])))]
|
(keys (get-in db [:communities community-id :chats])))]
|
||||||
{:clear-message-notifications [community-chat-ids
|
{:clear-message-notifications [community-chat-ids
|
||||||
(get-in db [:multiaccount :remote-push-notifications-enabled?])]
|
(get-in db [:multiaccount :remote-push-notifications-enabled?])]
|
||||||
|
:dispatch [:shell/close-switcher-card community-id]
|
||||||
:json-rpc/call [{:method "wakuext_leaveCommunity"
|
:json-rpc/call [{:method "wakuext_leaveCommunity"
|
||||||
:params [community-id]
|
:params [community-id]
|
||||||
:js-response true
|
:js-response true
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
(update :chats dissoc public-key)
|
(update :chats dissoc public-key)
|
||||||
(update :chats-home-list disj public-key)
|
(update :chats-home-list disj public-key)
|
||||||
(assoc-in [:contacts/contacts public-key :added] false))
|
(assoc-in [:contacts/contacts public-key :added] false))
|
||||||
|
:dispatch [:shell/close-switcher-card public-key]
|
||||||
:clear-message-notifications
|
:clear-message-notifications
|
||||||
[[public-key] (get-in db [:multiaccount :remote-push-notifications-enabled?])]}
|
[[public-key] (get-in db [:multiaccount :remote-push-notifications-enabled?])]}
|
||||||
(activity-center/notifications-fetch-unread-count)
|
(activity-center/notifications-fetch-unread-count)
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
{:events [:navigate-chat-updated]}
|
{:events [:navigate-chat-updated]}
|
||||||
[cofx chat-id]
|
[cofx chat-id]
|
||||||
(when (get-in cofx [:db :chats chat-id])
|
(when (get-in cofx [:db :chats chat-id])
|
||||||
(models.chat/navigate-to-chat cofx chat-id)))
|
(models.chat/navigate-to-chat-nav2 cofx chat-id nil)))
|
||||||
|
|
||||||
(rf/defn handle-chat-removed
|
(rf/defn handle-chat-removed
|
||||||
{:events [:chat-removed]}
|
{:events [:chat-removed]}
|
||||||
@ -71,7 +71,7 @@
|
|||||||
(rf/defn create-from-link
|
(rf/defn create-from-link
|
||||||
[cofx {:keys [chat-id invitation-admin chat-name]}]
|
[cofx {:keys [chat-id invitation-admin chat-name]}]
|
||||||
(if (get-in cofx [:db :chats chat-id])
|
(if (get-in cofx [:db :chats chat-id])
|
||||||
{:dispatch [:chat.ui/navigate-to-chat chat-id]}
|
{:dispatch [:chat.ui/navigate-to-chat-nav2 chat-id]}
|
||||||
{:json-rpc/call [{:method "wakuext_createGroupChatFromInvitation"
|
{:json-rpc/call [{:method "wakuext_createGroupChatFromInvitation"
|
||||||
:params [chat-name chat-id invitation-admin]
|
:params [chat-name chat-id invitation-admin]
|
||||||
:js-response true
|
:js-response true
|
||||||
|
@ -251,7 +251,7 @@
|
|||||||
(rf/dispatch-sync [:chat.ui/start-chat chat-id]) ;; start a new chat
|
(rf/dispatch-sync [:chat.ui/start-chat chat-id]) ;; start a new chat
|
||||||
(rf-test/wait-for
|
(rf-test/wait-for
|
||||||
[:status-im.chat.models/one-to-one-chat-created]
|
[:status-im.chat.models/one-to-one-chat-created]
|
||||||
(rf/dispatch-sync [:chat.ui/navigate-to-chat chat-id])
|
(rf/dispatch-sync [:chat.ui/navigate-to-chat-nav2 chat-id])
|
||||||
(is (= chat-id @(rf/subscribe [:chats/current-chat-id])))
|
(is (= chat-id @(rf/subscribe [:chats/current-chat-id])))
|
||||||
(logout!)
|
(logout!)
|
||||||
(rf-test/wait-for [::logout/logout-method] ; we need to logout to make sure the node is not in
|
(rf-test/wait-for [::logout/logout-method] ; we need to logout to make sure the node is not in
|
||||||
@ -276,7 +276,7 @@
|
|||||||
(rf/dispatch-sync [:chat.ui/start-chat chat-id]) ;; start a new chat
|
(rf/dispatch-sync [:chat.ui/start-chat chat-id]) ;; start a new chat
|
||||||
(rf-test/wait-for
|
(rf-test/wait-for
|
||||||
[:status-im.chat.models/one-to-one-chat-created]
|
[:status-im.chat.models/one-to-one-chat-created]
|
||||||
(rf/dispatch-sync [:chat.ui/navigate-to-chat chat-id])
|
(rf/dispatch-sync [:chat.ui/navigate-to-chat-nav2 chat-id])
|
||||||
(is (= chat-id @(rf/subscribe [:chats/current-chat-id])))
|
(is (= chat-id @(rf/subscribe [:chats/current-chat-id])))
|
||||||
(is @(rf/subscribe [:chats/chat chat-id]))
|
(is @(rf/subscribe [:chats/chat chat-id]))
|
||||||
(rf/dispatch-sync [:chat.ui/remove-chat-pressed chat-id])
|
(rf/dispatch-sync [:chat.ui/remove-chat-pressed chat-id])
|
||||||
@ -307,7 +307,7 @@
|
|||||||
(rf/dispatch-sync [:chat.ui/start-chat chat-id]) ;; start a new chat
|
(rf/dispatch-sync [:chat.ui/start-chat chat-id]) ;; start a new chat
|
||||||
(rf-test/wait-for
|
(rf-test/wait-for
|
||||||
[:status-im.chat.models/one-to-one-chat-created]
|
[:status-im.chat.models/one-to-one-chat-created]
|
||||||
(rf/dispatch-sync [:chat.ui/navigate-to-chat chat-id])
|
(rf/dispatch-sync [:chat.ui/navigate-to-chat-nav2 chat-id])
|
||||||
(is (= chat-id @(rf/subscribe [:chats/current-chat-id])))
|
(is (= chat-id @(rf/subscribe [:chats/current-chat-id])))
|
||||||
(is @(rf/subscribe [:chats/chat chat-id]))
|
(is @(rf/subscribe [:chats/chat chat-id]))
|
||||||
(rf/dispatch-sync [::chat.models/mute-chat-toggled chat-id true])
|
(rf/dispatch-sync [::chat.models/mute-chat-toggled chat-id true])
|
||||||
|
@ -424,7 +424,7 @@
|
|||||||
:key-uid
|
:key-uid
|
||||||
(fn [stored-key-uid]
|
(fn [stored-key-uid]
|
||||||
(when (= stored-key-uid key-uid)
|
(when (= stored-key-uid key-uid)
|
||||||
(re-frame/dispatch [:chat.ui/navigate-to-chat chat-id])))))))))
|
(re-frame/dispatch [:chat.ui/navigate-to-chat-nav2 chat-id])))))))))
|
||||||
|
|
||||||
(rf/defn check-last-chat
|
(rf/defn check-last-chat
|
||||||
{:events [::check-last-chat]}
|
{:events [::check-last-chat]}
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
:on-press (fn []
|
:on-press (fn []
|
||||||
(rf/dispatch [:communities/load-category-states id])
|
(rf/dispatch [:communities/load-category-states id])
|
||||||
(rf/dispatch [:dismiss-keyboard])
|
(rf/dispatch [:dismiss-keyboard])
|
||||||
(rf/dispatch [:navigate-to :community {:community-id id}]))
|
(rf/dispatch [:navigate-to-nav2 :community {:community-id id}]))
|
||||||
:on-long-press #(rf/dispatch [:bottom-sheet/show-sheet
|
:on-long-press #(rf/dispatch [:bottom-sheet/show-sheet
|
||||||
{:content (fn []
|
{:content (fn []
|
||||||
[community/community-actions community])}])}
|
[community/community-actions community])}])}
|
||||||
@ -111,7 +111,7 @@
|
|||||||
(i18n/label :t/open-membership))]]
|
(i18n/label :t/open-membership))]]
|
||||||
:on-press #(do
|
:on-press #(do
|
||||||
(rf/dispatch [:dismiss-keyboard])
|
(rf/dispatch [:dismiss-keyboard])
|
||||||
(rf/dispatch [:navigate-to :community {:community-id id}]))}]))
|
(rf/dispatch [:navigate-to-nav2 :community {:community-id id}]))}]))
|
||||||
|
|
||||||
(defn communities-actions
|
(defn communities-actions
|
||||||
[]
|
[]
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
[status-im.ui.screens.home.styles :as styles]
|
[status-im.ui.screens.home.styles :as styles]
|
||||||
[status-im.ui.screens.home.views.inner-item :as inner-item]
|
[status-im.ui.screens.home.views.inner-item :as inner-item]
|
||||||
[status-im.utils.utils :as utils]
|
[status-im.utils.utils :as utils]
|
||||||
[status-im2.setup.config :as config]
|
|
||||||
[utils.debounce :as debounce])
|
[utils.debounce :as debounce])
|
||||||
(:require-macros [status-im.utils.views :as views]))
|
(:require-macros [status-im.utils.views :as views]))
|
||||||
|
|
||||||
@ -152,9 +151,7 @@
|
|||||||
home-item
|
home-item
|
||||||
{:on-press (fn []
|
{:on-press (fn []
|
||||||
(re-frame/dispatch [:dismiss-keyboard])
|
(re-frame/dispatch [:dismiss-keyboard])
|
||||||
(if config/new-ui-enabled?
|
(re-frame/dispatch [:chat.ui/navigate-to-chat-nav2 chat-id])
|
||||||
(re-frame/dispatch [:chat.ui/navigate-to-chat-nav2 chat-id])
|
|
||||||
(re-frame/dispatch [:chat.ui/navigate-to-chat chat-id]))
|
|
||||||
(re-frame/dispatch [:search/home-filter-changed nil]))
|
(re-frame/dispatch [:search/home-filter-changed nil]))
|
||||||
:on-long-press #(re-frame/dispatch [:bottom-sheet/show-sheet
|
:on-long-press #(re-frame/dispatch [:bottom-sheet/show-sheet
|
||||||
{:content (fn []
|
{:content (fn []
|
||||||
@ -169,9 +166,7 @@
|
|||||||
home-item
|
home-item
|
||||||
{:on-press (fn []
|
{:on-press (fn []
|
||||||
(re-frame/dispatch [:dismiss-keyboard])
|
(re-frame/dispatch [:dismiss-keyboard])
|
||||||
(if config/new-ui-enabled?
|
(re-frame/dispatch [:chat.ui/navigate-to-chat-nav2 chat-id])
|
||||||
(re-frame/dispatch [:chat.ui/navigate-to-chat-nav2 chat-id])
|
|
||||||
(re-frame/dispatch [:chat.ui/navigate-to-chat chat-id]))
|
|
||||||
(re-frame/dispatch [:search/home-filter-changed nil]))
|
(re-frame/dispatch [:search/home-filter-changed nil]))
|
||||||
:on-long-press #(re-frame/dispatch [:bottom-sheet/show-sheet
|
:on-long-press #(re-frame/dispatch [:bottom-sheet/show-sheet
|
||||||
{:content (fn []
|
{:content (fn []
|
||||||
|
@ -96,7 +96,7 @@
|
|||||||
(rf/defn handle-community-chat
|
(rf/defn handle-community-chat
|
||||||
[cofx {:keys [chat-id]}]
|
[cofx {:keys [chat-id]}]
|
||||||
(log/info "universal-links: handling community chat" chat-id)
|
(log/info "universal-links: handling community chat" chat-id)
|
||||||
{:dispatch [:chat.ui/navigate-to-chat chat-id]})
|
{:dispatch [:chat.ui/navigate-to-chat-nav2 chat-id]})
|
||||||
|
|
||||||
(rf/defn handle-public-chat
|
(rf/defn handle-public-chat
|
||||||
[cofx {:keys [topic]}]
|
[cofx {:keys [topic]}]
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
[rn/touchable-opacity
|
[rn/touchable-opacity
|
||||||
{:on-press (fn []
|
{:on-press (fn []
|
||||||
(rf/dispatch [:hide-popover])
|
(rf/dispatch [:hide-popover])
|
||||||
(rf/dispatch [:chat.ui/navigate-to-chat chat-id]))}
|
(rf/dispatch [:chat.ui/navigate-to-chat-nav2 chat-id]))}
|
||||||
[quo/activity-log
|
[quo/activity-log
|
||||||
{:title (i18n/label :t/mention)
|
{:title (i18n/label :t/mention)
|
||||||
:icon :i/mention
|
:icon :i/mention
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
[rn/touchable-opacity
|
[rn/touchable-opacity
|
||||||
{:on-press (fn []
|
{:on-press (fn []
|
||||||
(rf/dispatch [:hide-popover])
|
(rf/dispatch [:hide-popover])
|
||||||
(rf/dispatch [:chat.ui/navigate-to-chat chat-id]))}
|
(rf/dispatch [:chat.ui/navigate-to-chat-nav2 chat-id]))}
|
||||||
[quo/activity-log
|
[quo/activity-log
|
||||||
{:title (i18n/label :t/message-reply)
|
{:title (i18n/label :t/message-reply)
|
||||||
:icon :i/reply
|
:icon :i/reply
|
||||||
|
@ -181,7 +181,7 @@
|
|||||||
[quo/floating-shell-button
|
[quo/floating-shell-button
|
||||||
(merge {:jump-to
|
(merge {:jump-to
|
||||||
{:on-press #(do
|
{:on-press #(do
|
||||||
(rf/dispatch [:close-chat])
|
(rf/dispatch [:close-chat true])
|
||||||
(rf/dispatch [:shell/navigate-to-jump-to]))
|
(rf/dispatch [:shell/navigate-to-jump-to]))
|
||||||
:label (i18n/label :t/jump-to)}}
|
:label (i18n/label :t/jump-to)}}
|
||||||
(when @show-floating-scroll-down-button
|
(when @show-floating-scroll-down-button
|
||||||
|
@ -19,7 +19,10 @@
|
|||||||
(when (and (not @navigation.state/curr-modal) (= (get @re-frame.db/app-db :view-id) :chat))
|
(when (and (not @navigation.state/curr-modal) (= (get @re-frame.db/app-db :view-id) :chat))
|
||||||
(rn/hw-back-remove-listener navigate-back-handler)
|
(rn/hw-back-remove-listener navigate-back-handler)
|
||||||
(rf/dispatch [:close-chat])
|
(rf/dispatch [:close-chat])
|
||||||
(rf/dispatch [:navigate-back])))
|
(rf/dispatch [:navigate-back])
|
||||||
|
;; If true is not returned back button event will bubble up,
|
||||||
|
;; and will call system back button action
|
||||||
|
true))
|
||||||
|
|
||||||
(defn page-nav
|
(defn page-nav
|
||||||
[]
|
[]
|
||||||
|
@ -102,7 +102,7 @@
|
|||||||
{:content {:community-channel {:emoji (:emoji channel)
|
{:content {:community-channel {:emoji (:emoji channel)
|
||||||
:channel-name (str "# " (:name channel))}}
|
:channel-name (str "# " (:name channel))}}
|
||||||
:on-press (fn []
|
:on-press (fn []
|
||||||
(re-frame/dispatch [:navigate-to :community {:community-id community-id}])
|
(re-frame/dispatch [:navigate-to-nav2 :community {:community-id community-id}])
|
||||||
(js/setTimeout
|
(js/setTimeout
|
||||||
#(re-frame/dispatch [:chat.ui/navigate-to-chat-nav2 channel-id true])
|
#(re-frame/dispatch [:chat.ui/navigate-to-chat-nav2 channel-id true])
|
||||||
100))}))
|
100))}))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user