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)}]])
(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

View File

@ -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])

View File

@ -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]))}])}))

View File

@ -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)]]]