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:
parent
028f959bc3
commit
76d6825dd5
|
@ -211,45 +211,44 @@
|
||||||
(let [show-delivery-state? (reagent/atom false)]
|
(let [show-delivery-state? (reagent/atom false)]
|
||||||
(fn [{:keys [message-data context keyboard-shown? hide-reactions?
|
(fn [{:keys [message-data context keyboard-shown? hide-reactions?
|
||||||
in-reaction-or-action-menu? show-user-info?]}]
|
in-reaction-or-action-menu? show-user-info?]}]
|
||||||
(let [theme (quo.theme/use-theme)
|
(let [theme (quo.theme/use-theme)
|
||||||
{:keys [content-type quoted-message content outgoing outgoing-status pinned-by pinned
|
{:keys [content-type quoted-message content outgoing outgoing-status pinned-by
|
||||||
bridge-message
|
pinned bridge-message last-in-group? message-id
|
||||||
last-in-group? message-id chat-id]} message-data
|
chat-id]} message-data
|
||||||
{:keys [disable-message-long-press?]} context
|
first-image (first (:album message-data))
|
||||||
first-image (first (:album message-data))
|
outgoing-status (if (= content-type
|
||||||
outgoing-status (if (= content-type
|
constants/content-type-album)
|
||||||
constants/content-type-album)
|
(:outgoing-status first-image)
|
||||||
(:outgoing-status first-image)
|
outgoing-status)
|
||||||
outgoing-status)
|
outgoing (if (= content-type
|
||||||
outgoing (if (= content-type
|
constants/content-type-album)
|
||||||
constants/content-type-album)
|
(:outgoing first-image)
|
||||||
(:outgoing first-image)
|
outgoing)
|
||||||
outgoing)
|
context (assoc context
|
||||||
context (assoc context
|
:on-long-press
|
||||||
:on-long-press
|
#(on-long-press message-data
|
||||||
#(on-long-press message-data
|
context
|
||||||
context
|
keyboard-shown?))
|
||||||
keyboard-shown?))
|
response-to (:response-to content)
|
||||||
response-to (:response-to content)
|
height (rf/sub [:dimensions/window-height])
|
||||||
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))
|
||||||
content-type (if (and
|
content-type (if (and
|
||||||
(= content-type
|
(= content-type
|
||||||
constants/content-type-bridge-message)
|
constants/content-type-bridge-message)
|
||||||
(seq (:parsed-text content)))
|
(seq (:parsed-text content)))
|
||||||
constants/content-type-text
|
constants/content-type-text
|
||||||
content-type)]
|
content-type)]
|
||||||
[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
|
||||||
|
@ -274,7 +273,7 @@
|
||||||
(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 (when-not disable-message-long-press?
|
:on-long-press (when-not (:disable-message-long-press? context)
|
||||||
#(on-long-press message-data context keyboard-shown?))}
|
#(on-long-press message-data context keyboard-shown?))}
|
||||||
[:<>
|
[:<>
|
||||||
(when pinned-by
|
(when pinned-by
|
||||||
|
@ -351,21 +350,20 @@
|
||||||
(rf/dispatch [:dismiss-keyboard])
|
(rf/dispatch [:dismiss-keyboard])
|
||||||
(rf/dispatch
|
(rf/dispatch
|
||||||
[:show-bottom-sheet
|
[:show-bottom-sheet
|
||||||
{:content (drawers/reactions-and-actions message-data context)
|
{:content (drawers/reactions-and-actions message-data context)
|
||||||
:border-radius 16
|
:border-radius 16
|
||||||
:selected-item
|
:selected-item (if (or deleted? deleted-for-me?)
|
||||||
(if (or deleted? deleted-for-me?)
|
(fn [] [content.deleted/deleted-message message-data])
|
||||||
(fn [] [content.deleted/deleted-message message-data])
|
(fn []
|
||||||
(fn []
|
[rn/view
|
||||||
[rn/view
|
{:pointer-events :none
|
||||||
{:pointer-events :none
|
:style style/drawer-message-container}
|
||||||
:style style/drawer-message-container}
|
[user-message-content
|
||||||
[user-message-content
|
{:message-data message-data
|
||||||
{:message-data message-data
|
:context context
|
||||||
:context context
|
:keyboard-shown? keyboard-shown?
|
||||||
:keyboard-shown? keyboard-shown?
|
:in-reaction-or-action-menu? true
|
||||||
:in-reaction-or-action-menu? true
|
:show-user-info? false}]]))}]))
|
||||||
:show-user-info? false}]]))}]))
|
|
||||||
|
|
||||||
(defn check-if-system-message?
|
(defn check-if-system-message?
|
||||||
[content-type]
|
[content-type]
|
||||||
|
|
|
@ -99,76 +99,92 @@
|
||||||
:as message-data}
|
:as message-data}
|
||||||
{:keys [able-to-send-message? community? community-member? 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?]}]
|
message-pin-enabled group-chat group-admin?]}]
|
||||||
(concat
|
(let [edit-message? (and (or community-member? (not community?))
|
||||||
(when (and outgoing
|
outgoing
|
||||||
(not (or deleted? deleted-for-me?))
|
(not (or deleted? deleted-for-me?))
|
||||||
;; temporarily disable edit image message until
|
;; 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
|
||||||
(not= content-type constants/content-type-image)
|
;; implemented
|
||||||
(not= content-type constants/content-type-audio))
|
(not= content-type constants/content-type-image)
|
||||||
[{:type :main
|
(not= content-type constants/content-type-audio))
|
||||||
:on-press #(rf/dispatch [:chat.ui/edit-message message-data])
|
reply? (and able-to-send-message?
|
||||||
:label (i18n/label :t/edit-message)
|
(not= outgoing-status :sending)
|
||||||
:icon :i/edit
|
(not (or deleted? deleted-for-me?)))
|
||||||
:accessibility-label :edit-message
|
copy-text? (and (not (or deleted? deleted-for-me?))
|
||||||
:id :edit}])
|
(not= content-type constants/content-type-audio))
|
||||||
(when (and able-to-send-message? (not= outgoing-status :sending) (not (or deleted? deleted-for-me?)))
|
;; pinning images are temporarily disabled
|
||||||
[{:type :main
|
pin-message? (and message-pin-enabled
|
||||||
:on-press #(rf/dispatch [:chat.ui/reply-to-message message-data])
|
(not= content-type constants/content-type-image)
|
||||||
:label (i18n/label :t/message-reply)
|
(or community-member? (not community?)))
|
||||||
:icon :i/reply
|
delete-for-me? (and (or community-member? (not community?))
|
||||||
:accessibility-label :reply-message
|
(not (or deleted? deleted-for-me? bridge-message)))
|
||||||
:id :reply}])
|
delete-for-everyone? (and (or community-member? (not community?))
|
||||||
(when (and (not (or deleted? deleted-for-me?))
|
(cond
|
||||||
(not= content-type constants/content-type-audio))
|
deleted? false
|
||||||
[{:type :main
|
outgoing true
|
||||||
:on-press #(clipboard/set-string
|
community? can-delete-message-for-everyone?
|
||||||
(reply/get-quoted-text-with-mentions
|
group-chat group-admin?
|
||||||
(get content :parsed-text)))
|
bridge-message false
|
||||||
:label (i18n/label :t/copy-text)
|
:else false))]
|
||||||
:accessibility-label :copy-text
|
(cond-> []
|
||||||
:icon :i/copy
|
reply?
|
||||||
:id :copy}])
|
(conj {:type :main
|
||||||
;; pinning images are temporarily disabled
|
:on-press #(rf/dispatch [:chat.ui/reply-to-message message-data])
|
||||||
(when (and message-pin-enabled
|
:label (i18n/label :t/message-reply)
|
||||||
(not= content-type constants/content-type-image)
|
:icon :i/reply
|
||||||
(or community-member? (not community?)))
|
:accessibility-label :reply-message
|
||||||
[{:type :main
|
:id :reply})
|
||||||
: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
|
|
||||||
:on-press (fn []
|
|
||||||
(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)
|
edit-message?
|
||||||
:accessibility-label :delete-for-me
|
(conj {:type :main
|
||||||
:icon :i/delete
|
:on-press #(rf/dispatch [:chat.ui/edit-message message-data])
|
||||||
:id :delete-for-me}])
|
:label (i18n/label :t/edit-message)
|
||||||
(when (cond
|
:icon :i/edit
|
||||||
deleted? false
|
:accessibility-label :edit-message
|
||||||
outgoing true
|
:id :edit})
|
||||||
community? can-delete-message-for-everyone?
|
|
||||||
group-chat group-admin?
|
copy-text?
|
||||||
bridge-message false
|
(conj {:type :main
|
||||||
:else false)
|
:on-press #(clipboard/set-string
|
||||||
[{:type :danger
|
(reply/get-quoted-text-with-mentions
|
||||||
:on-press (fn []
|
(get content :parsed-text)))
|
||||||
(rf/dispatch [:hide-bottom-sheet])
|
:label (i18n/label :t/copy-text)
|
||||||
(rf/dispatch [:chat.ui/delete-message message-data
|
:accessibility-label :copy-text
|
||||||
config/delete-message-undo-time-limit-ms]))
|
:icon :i/copy
|
||||||
:label (i18n/label :t/delete-for-everyone)
|
:id :copy})
|
||||||
:accessibility-label :delete-for-everyone
|
|
||||||
:icon :i/delete
|
pin-message?
|
||||||
:id :delete-for-all}])))
|
(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)})
|
||||||
|
|
||||||
|
delete-for-me?
|
||||||
|
(conj {:type :danger
|
||||||
|
:on-press (fn []
|
||||||
|
(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})
|
||||||
|
|
||||||
|
delete-for-everyone?
|
||||||
|
(conj {:type :danger
|
||||||
|
:on-press (fn []
|
||||||
|
(rf/dispatch [:hide-bottom-sheet])
|
||||||
|
(rf/dispatch [:chat.ui/delete-message message-data
|
||||||
|
config/delete-message-undo-time-limit-ms]))
|
||||||
|
:label (i18n/label :t/delete-for-everyone)
|
||||||
|
:accessibility-label :delete-for-everyone
|
||||||
|
:icon :i/delete
|
||||||
|
:id :delete-for-all}))))
|
||||||
|
|
||||||
(defn extract-id
|
(defn extract-id
|
||||||
[reactions id]
|
[reactions id]
|
||||||
|
@ -209,21 +225,24 @@
|
||||||
(rf/dispatch [:hide-bottom-sheet]))}])]))
|
(rf/dispatch [:hide-bottom-sheet]))}])]))
|
||||||
|
|
||||||
(defn reactions-and-actions
|
(defn reactions-and-actions
|
||||||
[message-data
|
[message-data {:keys [chat-id community? community-member?] :as context}]
|
||||||
{:keys [chat-id] :as context}]
|
|
||||||
(fn []
|
(fn []
|
||||||
(let [data (if (contains? message-data :album-id)
|
(let [data (if (contains? message-data :album-id)
|
||||||
(first (:album message-data))
|
(first (:album message-data))
|
||||||
message-data)
|
message-data)
|
||||||
{:keys [message-id deleted? deleted-for-me?]} data
|
{:keys [deleted-for-me?
|
||||||
outgoing-status (:outgoing-status data)
|
outgoing-status
|
||||||
actions (get-actions data context)
|
deleted?
|
||||||
main-actions (filter #(= (:type %) :main) actions)
|
message-id]} data
|
||||||
danger-actions (filter #(= (:type %) :danger) actions)
|
actions (get-actions data context)
|
||||||
admin-actions (filter #(= (:type %) :admin) actions)]
|
{main-actions :main
|
||||||
|
danger-actions :danger
|
||||||
|
admin-actions :admin} (group-by :type actions)]
|
||||||
[:<>
|
[:<>
|
||||||
;; REACTIONS
|
;; 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}])
|
[reactions {:chat-id chat-id :message-id message-id}])
|
||||||
;; MAIN ACTIONS
|
;; MAIN ACTIONS
|
||||||
[rn/view {:style {:padding-horizontal 8}}
|
[rn/view {:style {:padding-horizontal 8}}
|
||||||
|
|
|
@ -1,9 +1,15 @@
|
||||||
(ns status-im.contexts.chat.messenger.messages.scroll-to-bottom.style
|
(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
|
{: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
|
(def scroll-to-bottom-button
|
||||||
{:position :absolute
|
{:position :absolute
|
||||||
|
|
|
@ -12,8 +12,9 @@
|
||||||
scroll-down-button-opacity (worklets/scroll-down-button-opacity
|
scroll-down-button-opacity (worklets/scroll-down-button-opacity
|
||||||
chat-list-scroll-y
|
chat-list-scroll-y
|
||||||
false
|
false
|
||||||
window-height)]
|
window-height)
|
||||||
[rn/view {:style style/shell-button-container}
|
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
|
[quo/floating-shell-button
|
||||||
{:scroll-to-bottom {:on-press #(rf/dispatch [:chat.ui/scroll-to-bottom])}}
|
{:scroll-to-bottom {:on-press #(rf/dispatch [:chat.ui/scroll-to-bottom])}}
|
||||||
style/scroll-to-bottom-button
|
style/scroll-to-bottom-button
|
||||||
|
|
Loading…
Reference in New Issue