feat: show pinned messages bottom sheet in channel home (#19105)

This commit is contained in:
codemaster 2024-03-18 12:28:47 -07:00 committed by GitHub
parent e5cee4b640
commit 3b5afb5d60
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 43 additions and 35 deletions

View File

@ -33,7 +33,7 @@
:description (i18n/label :t/no-pinned-messages-desc)}]]) :description (i18n/label :t/no-pinned-messages-desc)}]])
(defn f-pinned-messages (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]) (let [pinned (rf/sub [:chats/pinned-sorted-list chat-id])
render-data (rf/sub [:chats/current-chat-message-list-view-context :in-pinned-view]) render-data (rf/sub [:chats/current-chat-message-list-view-context :in-pinned-view])
current-chat (rf/sub [:chats/chat-by-id chat-id]) current-chat (rf/sub [:chats/chat-by-id chat-id])
@ -60,7 +60,7 @@
(if (pos? (count pinned)) (if (pos? (count pinned))
[rn/flat-list [rn/flat-list
{:data pinned {:data pinned
:render-data render-data :render-data (assoc render-data :disable-message-long-press? disable-message-long-press?)
:render-fn message-render-fn :render-fn message-render-fn
:footer [rn/view {:style style/list-footer}] :footer [rn/view {:style style/list-footer}]
:key-fn list-key-fn :key-fn list-key-fn

View File

@ -152,35 +152,36 @@
show-user-info? preview? theme]}] show-user-info? preview? theme]}]
(let [{:keys [content-type quoted-message content (let [{:keys [content-type quoted-message content
outgoing outgoing-status pinned-by outgoing outgoing-status pinned-by
message-id chat-id]} message-data message-id chat-id]} message-data
first-image (first (:album message-data)) {:keys [disable-message-long-press?]} context
outgoing-status (if (= content-type first-image (first (:album message-data))
constants/content-type-album) outgoing-status (if (= content-type
(:outgoing-status first-image) constants/content-type-album)
outgoing-status) (:outgoing-status first-image)
outgoing (if (= content-type outgoing-status)
constants/content-type-album) outgoing (if (= content-type
(:outgoing first-image) constants/content-type-album)
outgoing) (:outgoing first-image)
context (assoc context outgoing)
:on-long-press context (assoc context
#(on-long-press message-data :on-long-press
context #(on-long-press message-data
keyboard-shown?)) context
response-to (:response-to content) keyboard-shown?))
height (rf/sub [:dimensions/window-height]) response-to (:response-to content)
height (rf/sub [:dimensions/window-height])
{window-width :width {window-width :width
window-scale :scale} (rn/get-window) window-scale :scale} (rn/get-window)
message-container-data {:window-width window-width message-container-data {:window-width window-width
:padding-right 20 :padding-right 20
:padding-left 20 :padding-left 20
:avatar-container-width 32 :avatar-container-width 32
:message-margin-left 8} :message-margin-left 8}
reactions (rf/sub [:chats/message-reactions message-id reactions (rf/sub [:chats/message-reactions message-id
chat-id]) chat-id])
six-reactions? (-> reactions six-reactions? (-> reactions
count count
(= 6))] (= 6))]
[rn/touchable-highlight [rn/touchable-highlight
{:accessibility-label (if (and outgoing (= outgoing-status :sending)) {:accessibility-label (if (and outgoing (= outgoing-status :sending))
:message-sending :message-sending
@ -204,7 +205,8 @@
(reset! show-delivery-state? true) (reset! show-delivery-state? true)
(js/setTimeout #(reset! show-delivery-state? false) (js/setTimeout #(reset! show-delivery-state? false)
delivery-state-showing-time-ms)))) 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 (when pinned-by
[pin/pinned-by-view pinned-by]) [pin/pinned-by-view pinned-by])

View File

@ -128,4 +128,8 @@
(rf/defn show-pins-bottom-sheet (rf/defn show-pins-bottom-sheet
{:events [:pin-message/show-pins-bottom-sheet]} {:events [:pin-message/show-pins-bottom-sheet]}
[cofx chat-id] [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]))}])}))

View File

@ -78,11 +78,13 @@
:sub-label (i18n/label :t/only-mentions)}) :sub-label (i18n/label :t/only-mentions)})
(defn- action-pinned-messages (defn- action-pinned-messages
[] [chat-id]
{:icon :i/pin {:icon :i/pin
:right-icon :i/chevron-right :right-icon :i/chevron-right
:accessibility-label :chat-pinned-messages :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)}) :label (i18n/label :t/pinned-messages)})
@ -124,7 +126,7 @@
(action-mark-as-read) (action-mark-as-read)
(action-toggle-muted chat-id muted muted-till chat-type) (action-toggle-muted chat-id muted muted-till chat-type)
(action-notification-settings) (action-notification-settings)
(action-pinned-messages) (action-pinned-messages chat-id)
(action-invite-people) (action-invite-people)
(action-qr-code chat-id) (action-qr-code chat-id)
(action-share chat-id)]]] (action-share chat-id)]]]