fix(communities): incorrect drawer for non community members (#21597)

* Fix wrong community modal shown for non-members

* Fix button overlapped in community chat for non-members

* Fix shown options order in modal
This commit is contained in:
Ulises Manuel 2024-11-12 09:36:17 -06:00 committed by GitHub
parent 028f959bc3
commit 76d6825dd5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 163 additions and 139 deletions

View File

@ -212,10 +212,9 @@
(fn [{:keys [message-data context keyboard-shown? hide-reactions?
in-reaction-or-action-menu? show-user-info?]}]
(let [theme (quo.theme/use-theme)
{:keys [content-type quoted-message content outgoing outgoing-status pinned-by pinned
bridge-message
last-in-group? message-id chat-id]} message-data
{:keys [disable-message-long-press?]} context
{:keys [content-type quoted-message content outgoing outgoing-status pinned-by
pinned bridge-message last-in-group? message-id
chat-id]} message-data
first-image (first (:album message-data))
outgoing-status (if (= content-type
constants/content-type-album)
@ -274,7 +273,7 @@
(reset! show-delivery-state? true)
(js/setTimeout #(reset! show-delivery-state? false)
delivery-state-showing-time-ms))))
:on-long-press (when-not disable-message-long-press?
:on-long-press (when-not (:disable-message-long-press? context)
#(on-long-press message-data context keyboard-shown?))}
[:<>
(when pinned-by
@ -353,8 +352,7 @@
[:show-bottom-sheet
{:content (drawers/reactions-and-actions message-data context)
:border-radius 16
:selected-item
(if (or deleted? deleted-for-me?)
:selected-item (if (or deleted? deleted-for-me?)
(fn [] [content.deleted/deleted-message message-data])
(fn []
[rn/view

View File

@ -99,68 +99,84 @@
:as message-data}
{:keys [able-to-send-message? community? community-member? can-delete-message-for-everyone?
message-pin-enabled group-chat group-admin?]}]
(concat
(when (and outgoing
(let [edit-message? (and (or community-member? (not community?))
outgoing
(not (or deleted? deleted-for-me?))
;; temporarily disable edit image message until
;; https://github.com/status-im/status-mobile/issues/15298 is implemented
;; https://github.com/status-im/status-mobile/issues/15298 is
;; implemented
(not= content-type constants/content-type-image)
(not= content-type constants/content-type-audio))
[{:type :main
:on-press #(rf/dispatch [:chat.ui/edit-message message-data])
:label (i18n/label :t/edit-message)
:icon :i/edit
:accessibility-label :edit-message
:id :edit}])
(when (and able-to-send-message? (not= outgoing-status :sending) (not (or deleted? deleted-for-me?)))
[{:type :main
reply? (and able-to-send-message?
(not= outgoing-status :sending)
(not (or deleted? deleted-for-me?)))
copy-text? (and (not (or deleted? deleted-for-me?))
(not= content-type constants/content-type-audio))
;; pinning images are temporarily disabled
pin-message? (and message-pin-enabled
(not= content-type constants/content-type-image)
(or community-member? (not community?)))
delete-for-me? (and (or community-member? (not community?))
(not (or deleted? deleted-for-me? bridge-message)))
delete-for-everyone? (and (or community-member? (not community?))
(cond
deleted? false
outgoing true
community? can-delete-message-for-everyone?
group-chat group-admin?
bridge-message false
:else false))]
(cond-> []
reply?
(conj {:type :main
:on-press #(rf/dispatch [:chat.ui/reply-to-message message-data])
:label (i18n/label :t/message-reply)
:icon :i/reply
:accessibility-label :reply-message
:id :reply}])
(when (and (not (or deleted? deleted-for-me?))
(not= content-type constants/content-type-audio))
[{:type :main
:id :reply})
edit-message?
(conj {:type :main
:on-press #(rf/dispatch [:chat.ui/edit-message message-data])
:label (i18n/label :t/edit-message)
:icon :i/edit
:accessibility-label :edit-message
:id :edit})
copy-text?
(conj {:type :main
:on-press #(clipboard/set-string
(reply/get-quoted-text-with-mentions
(get content :parsed-text)))
:label (i18n/label :t/copy-text)
:accessibility-label :copy-text
:icon :i/copy
:id :copy}])
;; pinning images are temporarily disabled
(when (and message-pin-enabled
(not= content-type constants/content-type-image)
(or community-member? (not community?)))
[{:type :main
:id :copy})
pin-message?
(conj {:type :main
:on-press #(pin-message message-data)
:label (i18n/label (if pinned-by
(if community? :t/unpin-from-channel :t/unpin-from-chat)
(if community? :t/pin-to-channel :t/pin-to-chat)))
:accessibility-label (if pinned-by :unpin-message :pin-message)
:icon :i/pin
:id (if pinned-by :unpin :pin)}])
(when-not (or deleted? deleted-for-me? bridge-message)
[{:type :danger
:id (if pinned-by :unpin :pin)})
delete-for-me?
(conj {:type :danger
:on-press (fn []
(rf/dispatch
[:hide-bottom-sheet])
(rf/dispatch [:hide-bottom-sheet])
(rf/dispatch [:chat.ui/delete-message-for-me message-data
config/delete-message-for-me-undo-time-limit-ms]))
:label (i18n/label :t/delete-for-me)
:accessibility-label :delete-for-me
:icon :i/delete
:id :delete-for-me}])
(when (cond
deleted? false
outgoing true
community? can-delete-message-for-everyone?
group-chat group-admin?
bridge-message false
:else false)
[{:type :danger
:id :delete-for-me})
delete-for-everyone?
(conj {:type :danger
:on-press (fn []
(rf/dispatch [:hide-bottom-sheet])
(rf/dispatch [:chat.ui/delete-message message-data
@ -168,7 +184,7 @@
:label (i18n/label :t/delete-for-everyone)
:accessibility-label :delete-for-everyone
:icon :i/delete
:id :delete-for-all}])))
:id :delete-for-all}))))
(defn extract-id
[reactions id]
@ -209,21 +225,24 @@
(rf/dispatch [:hide-bottom-sheet]))}])]))
(defn reactions-and-actions
[message-data
{:keys [chat-id] :as context}]
[message-data {:keys [chat-id community? community-member?] :as context}]
(fn []
(let [data (if (contains? message-data :album-id)
(first (:album message-data))
message-data)
{:keys [message-id deleted? deleted-for-me?]} data
outgoing-status (:outgoing-status data)
{:keys [deleted-for-me?
outgoing-status
deleted?
message-id]} data
actions (get-actions data context)
main-actions (filter #(= (:type %) :main) actions)
danger-actions (filter #(= (:type %) :danger) actions)
admin-actions (filter #(= (:type %) :admin) actions)]
{main-actions :main
danger-actions :danger
admin-actions :admin} (group-by :type actions)]
[:<>
;; REACTIONS
(when (and (not= outgoing-status :sending) (not (or deleted? deleted-for-me?)))
(when (and (or community-member? (not community?))
(not= outgoing-status :sending)
(not (or deleted? deleted-for-me?)))
[reactions {:chat-id chat-id :message-id message-id}])
;; MAIN ACTIONS
[rn/view {:style {:padding-horizontal 8}}

View File

@ -1,9 +1,15 @@
(ns status-im.contexts.chat.messenger.messages.scroll-to-bottom.style
(:require [status-im.contexts.shell.jump-to.constants :as shell.constants]))
(:require [react-native.safe-area :as safe-area]
[status-im.contexts.shell.jump-to.constants :as shell.constants]))
(def shell-button-container
(def ^:private bottom-drawer-height 46)
(defn shell-button-container
[able-to-send-messages?]
{:z-index 1
:bottom shell.constants/floating-shell-button-height})
:bottom (+ (safe-area/get-bottom)
(when-not able-to-send-messages? bottom-drawer-height)
shell.constants/floating-shell-button-height)})
(def scroll-to-bottom-button
{:position :absolute

View File

@ -12,8 +12,9 @@
scroll-down-button-opacity (worklets/scroll-down-button-opacity
chat-list-scroll-y
false
window-height)]
[rn/view {:style style/shell-button-container}
window-height)
able-to-send-message? (rf/sub [:chats/able-to-send-message?])]
[rn/view {:style (style/shell-button-container able-to-send-message?)}
[quo/floating-shell-button
{:scroll-to-bottom {:on-press #(rf/dispatch [:chat.ui/scroll-to-bottom])}}
style/scroll-to-bottom-button