fix(chats): Last message overlapped by the composer when a message is pinned (#20606)

* fixed overlapping last message by the composer when there is a pinned message

* prevent a user who is not a member of a community from pinning or unpinning channel messages

---------

Co-authored-by: Ulises M <ulises.ssb@hotmail.com>
This commit is contained in:
John Ngei 2024-09-10 01:19:10 +02:00 committed by GitHub
parent fa4ea0640d
commit d7242f1c70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 17 additions and 6 deletions

View File

@ -50,7 +50,7 @@
item])))))
(defn add-manage-members
[{:keys [scroll-enabled? on-scroll]}]
[{:keys [on-scroll]}]
(let [theme (quo.theme/use-theme)
selected-participants (rf/sub [:group-chat/selected-participants])
deselected-members (rf/sub [:group-chat/deselected-members])
@ -74,7 +74,6 @@
(i18n/label (if admin? :t/manage-members :t/add-members))]
[gesture/section-list
{:key-fn :title
:scroll-enabled @scroll-enabled?
:on-scroll on-scroll
:sticky-section-headers-enabled false
:sections (rf/sub [:contacts/grouped-by-first-letter])

View File

@ -97,7 +97,7 @@
[{:keys [outgoing content pinned-by outgoing-status deleted? deleted-for-me? content-type
bridge-message]
:as message-data}
{:keys [able-to-send-message? community? can-delete-message-for-everyone?
{:keys [able-to-send-message? community? community-member? can-delete-message-for-everyone?
message-pin-enabled group-chat group-admin?]}]
(concat
(when (and outgoing
@ -131,7 +131,8 @@
:id :copy}])
;; pinning images are temporarily disabled
(when (and message-pin-enabled
(not= content-type constants/content-type-image))
(not= content-type constants/content-type-image)
(or community-member? (not community?)))
[{:type :main
:on-press #(pin-message message-data)
:label (i18n/label (if pinned-by

View File

@ -5,6 +5,8 @@
[react-native.reanimated :as reanimated]
[status-im.contexts.chat.messenger.messages.constants :as messages.constants]))
(def permission-context-height 46)
(defn keyboard-avoiding-container
[theme]
{:flex 1
@ -73,3 +75,8 @@
(reanimated/apply-animations-to-style
{:top top}
{:row-gap 16}))
(defn permission-context-sheet
[margin-bottom?]
{:flex 3 ;; Pushes composer to bottom
:margin-bottom (when margin-bottom? permission-context-height)})

View File

@ -400,16 +400,18 @@
{:keys [keyboard-shown]} (hooks/use-keyboard)
{window-height :height} (rn/get-window)
context (rf/sub [:chats/current-chat-message-list-view-context])
able-to-send-message? (:able-to-send-message? context)
messages (rf/sub [:chats/raw-chat-messages-stream chat-id])
margin-bottom? (and community-channel? (not able-to-send-message?))
recording? (rf/sub [:chats/recording?])]
[rn/view {:style {:flex 3}} ;; Pushes composer to bottom
[rn/view {:style (style/permission-context-sheet margin-bottom?)}
[rn/view {:style {:flex-shrink 1}} ;; Keeps flat list on top
[reanimated/flat-list
{:key-fn list-key-fn
:ref list-ref
:bounces false
:header [:<>
[list-header insets (:able-to-send-message? context)]
[list-header insets able-to-send-message?]
(when (= (:chat-type chat) constants/private-group-chat-type)
[list-group-chat-header chat])]
:footer [list-footer

View File

@ -228,6 +228,7 @@
community? (some? current-community)
group-admin? (contains? admins current-public-key)
community-admin? (get current-community :admin false)
community-member? (get current-community :is-member? false)
message-pin-enabled
(cond public? false
@ -247,6 +248,7 @@
:chat-id chat-id
:in-pinned-view? (boolean in-pinned-view?)
:able-to-send-message? able-to-send-message?
:community-member? community-member?
:message-pin-enabled message-pin-enabled
:can-delete-message-for-everyone? can-delete-message-for-everyone?})))