diff --git a/src/react_native/reanimated.cljs b/src/react_native/reanimated.cljs index f397ff67f6..0a8c9afdb1 100644 --- a/src/react_native/reanimated.cljs +++ b/src/react_native/reanimated.cljs @@ -54,11 +54,13 @@ ;; Helper functions (defn get-shared-value [anim] - (.-value anim)) + (when anim + (.-value anim))) (defn set-shared-value [anim val] - (set! (.-value anim) val)) + (when anim + (set! (.-value anim) val))) (defn kebab-case->camelCase [k] diff --git a/src/status_im/chat/models.cljs b/src/status_im/chat/models.cljs index 1e6f024bf9..12c645d8bd 100644 --- a/src/status_im/chat/models.cljs +++ b/src/status_im/chat/models.cljs @@ -220,11 +220,17 @@ (rf/defn close-chat {:events [:close-chat]} - [{:keys [db] :as cofx}] + [{:keys [db] :as cofx} navigate-to-shell?] (when-let [chat-id (:current-chat-id db)] (chat.state/reset-visible-item) (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-message/send-all) (offload-messages chat-id)))) @@ -243,7 +249,8 @@ [{:keys [db now] :as cofx} chat-id] (rf/merge cofx {: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) (offload-messages chat-id))) @@ -268,7 +275,7 @@ (navigation/change-tab :chat) (when-not (= (:view-id db) :community) (navigation/pop-to-root-tab :chat-stack)) - (close-chat) + (close-chat false) (force-close-chat chat-id) (fn [{:keys [db]}] {:db (assoc db :current-chat-id chat-id)}) @@ -284,7 +291,7 @@ {:dispatch [:navigate-to-nav2 :chat chat-id from-shell?]} (when-not (= (:view-id db) :community) (navigation/pop-to-root-tab :shell-stack)) - (close-chat) + (close-chat false) (force-close-chat chat-id) (fn [{:keys [db]}] {:db (assoc db :current-chat-id chat-id)}) @@ -311,7 +318,7 @@ (assoc-in [:chats chat-id] chat) :always (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 "Takes coeffects map and chat-id, returns effects necessary for navigation and preloading data" diff --git a/src/status_im/communities/core.cljs b/src/status_im/communities/core.cljs index 9a55f7d4b3..6e7dc4e95b 100644 --- a/src/status_im/communities/core.cljs +++ b/src/status_im/communities/core.cljs @@ -187,6 +187,7 @@ (keys (get-in db [:communities community-id :chats])))] {:clear-message-notifications [community-chat-ids (get-in db [:multiaccount :remote-push-notifications-enabled?])] + :dispatch [:shell/close-switcher-card community-id] :json-rpc/call [{:method "wakuext_leaveCommunity" :params [community-id] :js-response true diff --git a/src/status_im/contact/block.cljs b/src/status_im/contact/block.cljs index 3ae9a6361d..423200f0f6 100644 --- a/src/status_im/contact/block.cljs +++ b/src/status_im/contact/block.cljs @@ -47,6 +47,7 @@ (update :chats dissoc public-key) (update :chats-home-list disj public-key) (assoc-in [:contacts/contacts public-key :added] false)) + :dispatch [:shell/close-switcher-card public-key] :clear-message-notifications [[public-key] (get-in db [:multiaccount :remote-push-notifications-enabled?])]} (activity-center/notifications-fetch-unread-count) diff --git a/src/status_im/group_chats/core.cljs b/src/status_im/group_chats/core.cljs index 7007fa640c..3826729640 100644 --- a/src/status_im/group_chats/core.cljs +++ b/src/status_im/group_chats/core.cljs @@ -14,7 +14,7 @@ {:events [:navigate-chat-updated]} [cofx 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 {:events [:chat-removed]} @@ -71,7 +71,7 @@ (rf/defn create-from-link [cofx {:keys [chat-id invitation-admin chat-name]}] (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" :params [chat-name chat-id invitation-admin] :js-response true diff --git a/src/status_im/integration_test.cljs b/src/status_im/integration_test.cljs index 0f21ed32e7..f816b75645 100644 --- a/src/status_im/integration_test.cljs +++ b/src/status_im/integration_test.cljs @@ -251,7 +251,7 @@ (rf/dispatch-sync [:chat.ui/start-chat chat-id]) ;; start a new chat (rf-test/wait-for [: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]))) (logout!) (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-test/wait-for [: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 @(rf/subscribe [:chats/chat 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-test/wait-for [: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 @(rf/subscribe [:chats/chat chat-id])) (rf/dispatch-sync [::chat.models/mute-chat-toggled chat-id true]) diff --git a/src/status_im/multiaccounts/login/core.cljs b/src/status_im/multiaccounts/login/core.cljs index 6b64a3bf02..657d9e3bd6 100644 --- a/src/status_im/multiaccounts/login/core.cljs +++ b/src/status_im/multiaccounts/login/core.cljs @@ -424,7 +424,7 @@ :key-uid (fn [stored-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 {:events [::check-last-chat]} diff --git a/src/status_im/ui/screens/communities/views.cljs b/src/status_im/ui/screens/communities/views.cljs index 36cb8e267a..5adacfbfbb 100644 --- a/src/status_im/ui/screens/communities/views.cljs +++ b/src/status_im/ui/screens/communities/views.cljs @@ -48,7 +48,7 @@ :on-press (fn [] (rf/dispatch [:communities/load-category-states id]) (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 {:content (fn [] [community/community-actions community])}])} @@ -111,7 +111,7 @@ (i18n/label :t/open-membership))]] :on-press #(do (rf/dispatch [:dismiss-keyboard]) - (rf/dispatch [:navigate-to :community {:community-id id}]))}])) + (rf/dispatch [:navigate-to-nav2 :community {:community-id id}]))}])) (defn communities-actions [] diff --git a/src/status_im/ui/screens/home/views.cljs b/src/status_im/ui/screens/home/views.cljs index 2104528bd3..9e9e2fe927 100644 --- a/src/status_im/ui/screens/home/views.cljs +++ b/src/status_im/ui/screens/home/views.cljs @@ -27,7 +27,6 @@ [status-im.ui.screens.home.styles :as styles] [status-im.ui.screens.home.views.inner-item :as inner-item] [status-im.utils.utils :as utils] - [status-im2.setup.config :as config] [utils.debounce :as debounce]) (:require-macros [status-im.utils.views :as views])) @@ -152,9 +151,7 @@ home-item {:on-press (fn [] (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 chat-id])) + (re-frame/dispatch [:chat.ui/navigate-to-chat-nav2 chat-id]) (re-frame/dispatch [:search/home-filter-changed nil])) :on-long-press #(re-frame/dispatch [:bottom-sheet/show-sheet {:content (fn [] @@ -169,9 +166,7 @@ home-item {:on-press (fn [] (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 chat-id])) + (re-frame/dispatch [:chat.ui/navigate-to-chat-nav2 chat-id]) (re-frame/dispatch [:search/home-filter-changed nil])) :on-long-press #(re-frame/dispatch [:bottom-sheet/show-sheet {:content (fn [] diff --git a/src/status_im/utils/universal_links/core.cljs b/src/status_im/utils/universal_links/core.cljs index 5df16ea621..085272c59d 100644 --- a/src/status_im/utils/universal_links/core.cljs +++ b/src/status_im/utils/universal_links/core.cljs @@ -96,7 +96,7 @@ (rf/defn handle-community-chat [cofx {:keys [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 [cofx {:keys [topic]}] diff --git a/src/status_im2/contexts/activity_center/notification/mentions/view.cljs b/src/status_im2/contexts/activity_center/notification/mentions/view.cljs index 27a08da1d8..415b341582 100644 --- a/src/status_im2/contexts/activity_center/notification/mentions/view.cljs +++ b/src/status_im2/contexts/activity_center/notification/mentions/view.cljs @@ -46,7 +46,7 @@ [rn/touchable-opacity {:on-press (fn [] (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 {:title (i18n/label :t/mention) :icon :i/mention diff --git a/src/status_im2/contexts/activity_center/notification/reply/view.cljs b/src/status_im2/contexts/activity_center/notification/reply/view.cljs index b6d32369a6..74b80db555 100644 --- a/src/status_im2/contexts/activity_center/notification/reply/view.cljs +++ b/src/status_im2/contexts/activity_center/notification/reply/view.cljs @@ -38,7 +38,7 @@ [rn/touchable-opacity {:on-press (fn [] (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 {:title (i18n/label :t/message-reply) :icon :i/reply diff --git a/src/status_im2/contexts/chat/messages/list/view.cljs b/src/status_im2/contexts/chat/messages/list/view.cljs index 478e7fd822..b225990ca0 100644 --- a/src/status_im2/contexts/chat/messages/list/view.cljs +++ b/src/status_im2/contexts/chat/messages/list/view.cljs @@ -181,7 +181,7 @@ [quo/floating-shell-button (merge {:jump-to {:on-press #(do - (rf/dispatch [:close-chat]) + (rf/dispatch [:close-chat true]) (rf/dispatch [:shell/navigate-to-jump-to])) :label (i18n/label :t/jump-to)}} (when @show-floating-scroll-down-button diff --git a/src/status_im2/contexts/chat/messages/view.cljs b/src/status_im2/contexts/chat/messages/view.cljs index 9f71a87b42..377e14ca6f 100644 --- a/src/status_im2/contexts/chat/messages/view.cljs +++ b/src/status_im2/contexts/chat/messages/view.cljs @@ -19,7 +19,10 @@ (when (and (not @navigation.state/curr-modal) (= (get @re-frame.db/app-db :view-id) :chat)) (rn/hw-back-remove-listener navigate-back-handler) (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 [] diff --git a/src/status_im2/subs/shell.cljs b/src/status_im2/subs/shell.cljs index 97e9f571b4..78896fc5f9 100644 --- a/src/status_im2/subs/shell.cljs +++ b/src/status_im2/subs/shell.cljs @@ -102,7 +102,7 @@ {:content {:community-channel {:emoji (:emoji channel) :channel-name (str "# " (:name channel))}} :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 #(re-frame/dispatch [:chat.ui/navigate-to-chat-nav2 channel-id true]) 100))}))