From 3b5afb5d609831084448f8dc9b10a0ea717e640c Mon Sep 17 00:00:00 2001 From: codemaster <39961806+codemaster115@users.noreply.github.com> Date: Mon, 18 Mar 2024 12:28:47 -0700 Subject: [PATCH] feat: show pinned messages bottom sheet in channel home (#19105) --- .../messenger/menus/pinned_messages/view.cljs | 4 +- .../chat/messenger/messages/content/view.cljs | 60 ++++++++++--------- .../chat/messenger/messages/pin/events.cljs | 6 +- .../communities/actions/chat/view.cljs | 8 ++- 4 files changed, 43 insertions(+), 35 deletions(-) diff --git a/src/status_im/contexts/chat/messenger/menus/pinned_messages/view.cljs b/src/status_im/contexts/chat/messenger/menus/pinned_messages/view.cljs index 14c233deff..d963b7a828 100644 --- a/src/status_im/contexts/chat/messenger/menus/pinned_messages/view.cljs +++ b/src/status_im/contexts/chat/messenger/menus/pinned_messages/view.cljs @@ -33,7 +33,7 @@ :description (i18n/label :t/no-pinned-messages-desc)}]]) (defn f-pinned-messages - [{:keys [theme chat-id]}] + [{:keys [theme chat-id disable-message-long-press?]}] (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 [:chats/chat-by-id chat-id]) @@ -60,7 +60,7 @@ (if (pos? (count pinned)) [rn/flat-list {:data pinned - :render-data render-data + :render-data (assoc render-data :disable-message-long-press? disable-message-long-press?) :render-fn message-render-fn :footer [rn/view {:style style/list-footer}] :key-fn list-key-fn diff --git a/src/status_im/contexts/chat/messenger/messages/content/view.cljs b/src/status_im/contexts/chat/messenger/messages/content/view.cljs index 77eb1df483..5eeee5e046 100644 --- a/src/status_im/contexts/chat/messenger/messages/content/view.cljs +++ b/src/status_im/contexts/chat/messenger/messages/content/view.cljs @@ -152,35 +152,36 @@ show-user-info? preview? theme]}] (let [{:keys [content-type quoted-message content outgoing outgoing-status pinned-by - message-id chat-id]} message-data - first-image (first (:album message-data)) - outgoing-status (if (= content-type - constants/content-type-album) - (:outgoing-status first-image) - outgoing-status) - outgoing (if (= content-type - constants/content-type-album) - (:outgoing first-image) - outgoing) - context (assoc context - :on-long-press - #(on-long-press message-data - context - keyboard-shown?)) - response-to (:response-to content) - height (rf/sub [:dimensions/window-height]) + message-id chat-id]} message-data + {:keys [disable-message-long-press?]} context + first-image (first (:album message-data)) + outgoing-status (if (= content-type + constants/content-type-album) + (:outgoing-status first-image) + outgoing-status) + outgoing (if (= content-type + constants/content-type-album) + (:outgoing first-image) + outgoing) + context (assoc context + :on-long-press + #(on-long-press message-data + context + keyboard-shown?)) + response-to (:response-to content) + height (rf/sub [:dimensions/window-height]) {window-width :width - window-scale :scale} (rn/get-window) - message-container-data {:window-width window-width - :padding-right 20 - :padding-left 20 - :avatar-container-width 32 - :message-margin-left 8} - reactions (rf/sub [:chats/message-reactions message-id - chat-id]) - six-reactions? (-> reactions - count - (= 6))] + window-scale :scale} (rn/get-window) + message-container-data {:window-width window-width + :padding-right 20 + :padding-left 20 + :avatar-container-width 32 + :message-margin-left 8} + reactions (rf/sub [:chats/message-reactions message-id + chat-id]) + six-reactions? (-> reactions + count + (= 6))] [rn/touchable-highlight {:accessibility-label (if (and outgoing (= outgoing-status :sending)) :message-sending @@ -204,7 +205,8 @@ (reset! show-delivery-state? true) (js/setTimeout #(reset! show-delivery-state? false) delivery-state-showing-time-ms)))) - :on-long-press #(on-long-press message-data context keyboard-shown?)} + :on-long-press (when-not disable-message-long-press? + #(on-long-press message-data context keyboard-shown?))} [:<> (when pinned-by [pin/pinned-by-view pinned-by]) diff --git a/src/status_im/contexts/chat/messenger/messages/pin/events.cljs b/src/status_im/contexts/chat/messenger/messages/pin/events.cljs index 3cfc6a56dd..d35acbef81 100644 --- a/src/status_im/contexts/chat/messenger/messages/pin/events.cljs +++ b/src/status_im/contexts/chat/messenger/messages/pin/events.cljs @@ -128,4 +128,8 @@ (rf/defn show-pins-bottom-sheet {:events [:pin-message/show-pins-bottom-sheet]} [cofx chat-id] - (navigation/show-bottom-sheet cofx {:content (fn [] [pinned-messages-menu/view {:chat-id chat-id}])})) + (navigation/show-bottom-sheet + cofx + {:content (fn [] [pinned-messages-menu/view + {:chat-id chat-id + :disable-message-long-press? (not= :chat (get-in cofx [:db :view-id]))}])})) diff --git a/src/status_im/contexts/communities/actions/chat/view.cljs b/src/status_im/contexts/communities/actions/chat/view.cljs index e65c4218ff..8f911e217d 100644 --- a/src/status_im/contexts/communities/actions/chat/view.cljs +++ b/src/status_im/contexts/communities/actions/chat/view.cljs @@ -78,11 +78,13 @@ :sub-label (i18n/label :t/only-mentions)}) (defn- action-pinned-messages - [] + [chat-id] {:icon :i/pin :right-icon :i/chevron-right :accessibility-label :chat-pinned-messages - :on-press not-implemented/alert + :on-press (fn [] + (rf/dispatch [:pin-message/load-pin-messages chat-id]) + (rf/dispatch [:pin-message/show-pins-bottom-sheet chat-id])) :label (i18n/label :t/pinned-messages)}) @@ -124,7 +126,7 @@ (action-mark-as-read) (action-toggle-muted chat-id muted muted-till chat-type) (action-notification-settings) - (action-pinned-messages) + (action-pinned-messages chat-id) (action-invite-people) (action-qr-code chat-id) (action-share chat-id)]]]