diff --git a/src/legacy/status_im/group_chats/core.cljs b/src/legacy/status_im/group_chats/core.cljs index ab9b694d8786..5e6cf98b288c 100644 --- a/src/legacy/status_im/group_chats/core.cljs +++ b/src/legacy/status_im/group_chats/core.cljs @@ -242,15 +242,6 @@ [{db :db}] {:db (assoc db :group-chat/deselected-members #{})}) -(rf/defn show-group-chat-profile - {:events [:show-group-chat-profile]} - [{:keys [db] :as cofx} chat-id] - (rf/merge cofx - {:db (-> db - (assoc :new-chat-name (get-in db [:chats chat-id :name])) - (assoc :current-chat-id chat-id))} - (navigation/navigate-to :group-chat-profile nil))) - (rf/defn ui-leave-chat-pressed {:events [:group-chats.ui/leave-chat-pressed]} [{:keys [db]} chat-id] diff --git a/src/status_im/common/home/actions/view.cljs b/src/status_im/common/home/actions/view.cljs index dea4ecd64813..d7679646d97f 100644 --- a/src/status_im/common/home/actions/view.cljs +++ b/src/status_im/common/home/actions/view.cljs @@ -348,7 +348,7 @@ [chat-id] (entry {:icon :i/members :label (i18n/label :t/group-details) - :on-press #(hide-sheet-and-dispatch [:show-group-chat-profile chat-id]) + :on-press #(hide-sheet-and-dispatch [:navigate-to :group-chat-profile chat-id]) :danger? false :accessibility-label :group-details :sub-label nil diff --git a/src/status_im/contexts/chat/group_details/view.cljs b/src/status_im/contexts/chat/group_details/view.cljs index 8db6e0fc8f49..20b3fef70cc0 100644 --- a/src/status_im/contexts/chat/group_details/view.cljs +++ b/src/status_im/contexts/chat/group_details/view.cljs @@ -20,9 +20,7 @@ :icon-only? true :container-style {:margin-left 20} :accessibility-label :back-button - :on-press (fn [] - (rf/dispatch [:navigate-back]) - (rf/dispatch [:chat/close]))} + :on-press #(rf/dispatch [:navigate-back])} :i/arrow-left]) (defn options-button @@ -151,84 +149,78 @@ :on-press show-profile-actions}}) item])) -(defn f-group-details - [] - (fn [] - (rn/use-effect (fn [] - #(rf/dispatch [:chat/close]))) - (let [{:keys [admins chat-id chat-name color public? - muted contacts]} (rf/sub [:chats/current-chat]) - members (rf/sub [:contacts/group-members-sections]) - pinned-messages (rf/sub [:chats/pinned chat-id]) - current-pk (rf/sub [:multiaccount/public-key]) - admin? (get admins current-pk)] - [rn/view - {:style {:flex 1 - :background-color (colors/theme-colors colors/white colors/neutral-95)}} - [quo/header - {:left-component [back-button] - :right-component [options-button] - :background (colors/theme-colors colors/white colors/neutral-95)}] - [rn/view - {:style {:flex-direction :row - :margin-top 24 - :padding-horizontal 20}} - [quo/group-avatar - {:customization-color color - :size :size-32}] - [quo/text - {:weight :semi-bold - :size :heading-1 - :style {:margin-horizontal 8}} chat-name] - [rn/view {:style {:margin-top 8}} - [quo/icon (if public? :i/world :i/privacy) - {:size 20 :color (colors/theme-colors colors/neutral-50 colors/neutral-40)}]]] - [rn/view {:style (style/actions-view)} - [rn/touchable-opacity - {:style (style/action-container color) - :accessibility-label :pinned-messages - :on-press (fn [] - (rf/dispatch [:dismiss-keyboard]) - (rf/dispatch [:pin-message/show-pins-bottom-sheet chat-id]))} - [rn/view - {:style {:flex-direction :row - :justify-content :space-between}} - [quo/icon :i/pin {:size 20 :color (colors/theme-colors colors/neutral-100 colors/white)}] - [count-container (count pinned-messages) :pinned-count]] - [quo/text {:style {:margin-top 16} :size :paragraph-1 :weight :medium} - (i18n/label :t/pinned-messages)]] - [rn/touchable-opacity - {:style (style/action-container color) - :accessibility-label :toggle-mute - :on-press #(rf/dispatch [:chat.ui/mute chat-id (not muted) - (when-not muted constants/mute-till-unmuted)])} - [quo/icon (if muted :i/muted :i/activity-center) - {:size 20 :color (colors/theme-colors colors/neutral-100 colors/white)}] - [quo/text {:style {:margin-top 16} :size :paragraph-1 :weight :medium} - (i18n/label (if muted :unmute-group :mute-group))]] - [rn/touchable-opacity - {:style (style/action-container color) - :accessibility-label :manage-members - :on-press (fn [] - (rf/dispatch [:group/clear-added-participants]) - (rf/dispatch [:group/clear-removed-members]) - (rf/dispatch [:open-modal :group-add-manage-members]))} - [rn/view - {:style {:flex-direction :row - :justify-content :space-between}} - [quo/icon :i/add-user {:size 20 :color (colors/theme-colors colors/neutral-100 colors/white)}] - [count-container (count contacts) :members-count]] - [quo/text {:style {:margin-top 16} :size :paragraph-1 :weight :medium} - (i18n/label (if admin? :t/manage-members :t/add-members))]]] - [rn/section-list - {:key-fn :title - :sticky-section-headers-enabled false - :sections members - :render-section-header-fn contacts-section-header - :render-data {:chat-id chat-id - :admin? admin?} - :render-fn contact-item-render}]]))) - (defn group-details [] - [:f> f-group-details]) + (let [chat-id (rf/sub [:get-screen-params :group-chat-profile]) + {:keys [admins chat-id chat-name color public? + muted contacts]} (rf/sub [:chats/chat-by-id chat-id]) + members (rf/sub [:contacts/group-members-sections]) + pinned-messages (rf/sub [:chats/pinned chat-id]) + current-pk (rf/sub [:multiaccount/public-key]) + admin? (get admins current-pk)] + [rn/view + {:style {:flex 1 + :background-color (colors/theme-colors colors/white colors/neutral-95)}} + [quo/header + {:left-component [back-button] + :right-component [options-button] + :background (colors/theme-colors colors/white colors/neutral-95)}] + [rn/view + {:style {:flex-direction :row + :margin-top 24 + :padding-horizontal 20}} + [quo/group-avatar + {:customization-color color + :size :size-32}] + [quo/text + {:weight :semi-bold + :size :heading-1 + :style {:margin-horizontal 8}} chat-name] + [rn/view {:style {:margin-top 8}} + [quo/icon (if public? :i/world :i/privacy) + {:size 20 :color (colors/theme-colors colors/neutral-50 colors/neutral-40)}]]] + [rn/view {:style (style/actions-view)} + [rn/touchable-opacity + {:style (style/action-container color) + :accessibility-label :pinned-messages + :on-press (fn [] + (rf/dispatch [:dismiss-keyboard]) + (rf/dispatch [:pin-message/show-pins-bottom-sheet chat-id]))} + [rn/view + {:style {:flex-direction :row + :justify-content :space-between}} + [quo/icon :i/pin {:size 20 :color (colors/theme-colors colors/neutral-100 colors/white)}] + [count-container (count pinned-messages) :pinned-count]] + [quo/text {:style {:margin-top 16} :size :paragraph-1 :weight :medium} + (i18n/label :t/pinned-messages)]] + [rn/touchable-opacity + {:style (style/action-container color) + :accessibility-label :toggle-mute + :on-press #(rf/dispatch [:chat.ui/mute chat-id (not muted) + (when-not muted constants/mute-till-unmuted)])} + [quo/icon (if muted :i/muted :i/activity-center) + {:size 20 :color (colors/theme-colors colors/neutral-100 colors/white)}] + [quo/text {:style {:margin-top 16} :size :paragraph-1 :weight :medium} + (i18n/label (if muted :unmute-group :mute-group))]] + [rn/touchable-opacity + {:style (style/action-container color) + :accessibility-label :manage-members + :on-press (fn [] + (rf/dispatch [:group/clear-added-participants]) + (rf/dispatch [:group/clear-removed-members]) + (rf/dispatch [:open-modal :group-add-manage-members]))} + [rn/view + {:style {:flex-direction :row + :justify-content :space-between}} + [quo/icon :i/add-user {:size 20 :color (colors/theme-colors colors/neutral-100 colors/white)}] + [count-container (count contacts) :members-count]] + [quo/text {:style {:margin-top 16} :size :paragraph-1 :weight :medium} + (i18n/label (if admin? :t/manage-members :t/add-members))]]] + [rn/section-list + {:key-fn :title + :sticky-section-headers-enabled false + :sections members + :render-section-header-fn contacts-section-header + :render-data {:chat-id chat-id + :admin? admin?} + :render-fn contact-item-render}]])) diff --git a/src/status_im/contexts/chat/home/view.cljs b/src/status_im/contexts/chat/home/view.cljs index 53e3fbe30cb9..aafe721a9403 100644 --- a/src/status_im/contexts/chat/home/view.cljs +++ b/src/status_im/contexts/chat/home/view.cljs @@ -48,7 +48,7 @@ (defn chats [{:keys [theme selected-tab set-scroll-ref scroll-shared-value]}] - (let [unfiltered-items (rf/sub [:chats-stack-items]) + (let [unfiltered-items (rf/sub [:chats/chat-stack-items]) items (filter-and-sort-items-by-tab selected-tab unfiltered-items)] (if (empty? items) [common.empty-state/view diff --git a/src/status_im/contexts/chat/menus/pinned_messages/view.cljs b/src/status_im/contexts/chat/menus/pinned_messages/view.cljs index 4c26c9f41d04..ab28cecfcef6 100644 --- a/src/status_im/contexts/chat/menus/pinned_messages/view.cljs +++ b/src/status_im/contexts/chat/menus/pinned_messages/view.cljs @@ -46,7 +46,7 @@ [chat-id] (let [pinned (rf/sub [:chats/pinned-sorted-list chat-id]) render-data (rf/sub [:chats/current-chat-message-list-view-context :in-pinned-view]) - current-chat (rf/sub [:chat-by-id chat-id]) + current-chat (rf/sub [:chats/chat-by-id chat-id]) {:keys [community-id]} current-chat community (rf/sub [:communities/community community-id]) community-images (rf/sub [:community/images community-id])] diff --git a/src/status_im/contexts/chat/messages/list/view.cljs b/src/status_im/contexts/chat/messages/list/view.cljs index 3389a63b7977..8a532f81c3e7 100644 --- a/src/status_im/contexts/chat/messages/list/view.cljs +++ b/src/status_im/contexts/chat/messages/list/view.cljs @@ -155,7 +155,7 @@ [chat-id cover-bg-color] (let [latest-pin-text (rf/sub [:chats/last-pinned-message-text chat-id]) pins-count (rf/sub [:chats/pin-messages-count chat-id]) - {:keys [muted muted-till chat-type]} (rf/sub [:chat-by-id chat-id]) + {:keys [muted muted-till chat-type]} (rf/sub [:chats/chat-by-id chat-id]) community-channel? (= constants/community-chat-type chat-type) muted? (and muted (some? muted-till)) mute-chat-label (if community-channel? :t/mute-channel :t/mute-chat) diff --git a/src/status_im/contexts/communities/actions/chat/view.cljs b/src/status_im/contexts/communities/actions/chat/view.cljs index 76d8f766404a..ed57bb631fee 100644 --- a/src/status_im/contexts/communities/actions/chat/view.cljs +++ b/src/status_im/contexts/communities/actions/chat/view.cljs @@ -109,7 +109,7 @@ (defn actions [{:keys [locked? chat-id]} inside-chat?] - (let [{:keys [muted muted-till chat-type]} (rf/sub [:chat-by-id chat-id])] + (let [{:keys [muted muted-till chat-type]} (rf/sub [:chats/chat-by-id chat-id])] (cond locked? [quo/action-drawer diff --git a/src/status_im/subs/chats.cljs b/src/status_im/subs/chats.cljs index 9aa4493a344a..68b686c5dfe8 100644 --- a/src/status_im/subs/chats.cljs +++ b/src/status_im/subs/chats.cljs @@ -12,7 +12,7 @@ (def memo-chats-stack-items (atom nil)) (re-frame/reg-sub - :chats-stack-items + :chats/chat-stack-items :<- [:chats/home-list-chats] :<- [:view-id] :<- [:home-items-show-number] @@ -102,7 +102,7 @@ active-chats))) (re-frame/reg-sub - :chat-by-id + :chats/chat-by-id :<- [:chats/chats] (fn [chats [_ chat-id]] (get chats chat-id))) @@ -110,35 +110,35 @@ (re-frame/reg-sub :chats/synced-from (fn [[_ chat-id] _] - (re-frame/subscribe [:chat-by-id chat-id])) + (re-frame/subscribe [:chats/chat-by-id chat-id])) (fn [{:keys [synced-from]}] synced-from)) (re-frame/reg-sub :chats/muted (fn [[_ chat-id] _] - (re-frame/subscribe [:chat-by-id chat-id])) + (re-frame/subscribe [:chats/chat-by-id chat-id])) (fn [{:keys [muted]}] muted)) (re-frame/reg-sub :chats/chat-type (fn [[_ chat-id] _] - (re-frame/subscribe [:chat-by-id chat-id])) + (re-frame/subscribe [:chats/chat-by-id chat-id])) (fn [{:keys [chat-type]}] chat-type)) (re-frame/reg-sub :chats/joined (fn [[_ chat-id] _] - (re-frame/subscribe [:chat-by-id chat-id])) + (re-frame/subscribe [:chats/chat-by-id chat-id])) (fn [{:keys [joined]}] joined)) (re-frame/reg-sub :chats/synced-to-and-from (fn [[_ chat-id] _] - (re-frame/subscribe [:chat-by-id chat-id])) + (re-frame/subscribe [:chats/chat-by-id chat-id])) (fn [chat] (select-keys chat [:synced-to :synced-from]))) @@ -395,7 +395,7 @@ (re-frame/reg-sub :group-chat/inviter-info (fn [[_ chat-id] _] - [(re-frame/subscribe [:chat-by-id chat-id]) + [(re-frame/subscribe [:chats/chat-by-id chat-id]) (re-frame/subscribe [:multiaccount/public-key])]) (fn [[chat my-public-key]] {:member? (group-chats.db/member? my-public-key chat)