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
|
@ -212,10 +212,9 @@
|
||||||
(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)
|
||||||
|
@ -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
|
||||||
|
@ -353,8 +352,7 @@
|
||||||
[: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
|
||||||
|
|
|
@ -99,68 +99,84 @@
|
||||||
: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
|
||||||
|
;; implemented
|
||||||
(not= content-type constants/content-type-image)
|
(not= content-type constants/content-type-image)
|
||||||
(not= content-type constants/content-type-audio))
|
(not= content-type constants/content-type-audio))
|
||||||
[{:type :main
|
reply? (and able-to-send-message?
|
||||||
:on-press #(rf/dispatch [:chat.ui/edit-message message-data])
|
(not= outgoing-status :sending)
|
||||||
:label (i18n/label :t/edit-message)
|
(not (or deleted? deleted-for-me?)))
|
||||||
:icon :i/edit
|
copy-text? (and (not (or deleted? deleted-for-me?))
|
||||||
:accessibility-label :edit-message
|
(not= content-type constants/content-type-audio))
|
||||||
:id :edit}])
|
;; pinning images are temporarily disabled
|
||||||
(when (and able-to-send-message? (not= outgoing-status :sending) (not (or deleted? deleted-for-me?)))
|
pin-message? (and message-pin-enabled
|
||||||
[{:type :main
|
(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])
|
:on-press #(rf/dispatch [:chat.ui/reply-to-message message-data])
|
||||||
:label (i18n/label :t/message-reply)
|
:label (i18n/label :t/message-reply)
|
||||||
:icon :i/reply
|
:icon :i/reply
|
||||||
:accessibility-label :reply-message
|
:accessibility-label :reply-message
|
||||||
:id :reply}])
|
:id :reply})
|
||||||
(when (and (not (or deleted? deleted-for-me?))
|
|
||||||
(not= content-type constants/content-type-audio))
|
edit-message?
|
||||||
[{:type :main
|
(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
|
:on-press #(clipboard/set-string
|
||||||
(reply/get-quoted-text-with-mentions
|
(reply/get-quoted-text-with-mentions
|
||||||
(get content :parsed-text)))
|
(get content :parsed-text)))
|
||||||
:label (i18n/label :t/copy-text)
|
:label (i18n/label :t/copy-text)
|
||||||
:accessibility-label :copy-text
|
:accessibility-label :copy-text
|
||||||
:icon :i/copy
|
:icon :i/copy
|
||||||
:id :copy}])
|
:id :copy})
|
||||||
;; pinning images are temporarily disabled
|
|
||||||
(when (and message-pin-enabled
|
pin-message?
|
||||||
(not= content-type constants/content-type-image)
|
(conj {:type :main
|
||||||
(or community-member? (not community?)))
|
|
||||||
[{:type :main
|
|
||||||
:on-press #(pin-message message-data)
|
:on-press #(pin-message message-data)
|
||||||
:label (i18n/label (if pinned-by
|
:label (i18n/label (if pinned-by
|
||||||
(if community? :t/unpin-from-channel :t/unpin-from-chat)
|
(if community? :t/unpin-from-channel :t/unpin-from-chat)
|
||||||
(if community? :t/pin-to-channel :t/pin-to-chat)))
|
(if community? :t/pin-to-channel :t/pin-to-chat)))
|
||||||
:accessibility-label (if pinned-by :unpin-message :pin-message)
|
:accessibility-label (if pinned-by :unpin-message :pin-message)
|
||||||
:icon :i/pin
|
:icon :i/pin
|
||||||
:id (if pinned-by :unpin :pin)}])
|
:id (if pinned-by :unpin :pin)})
|
||||||
(when-not (or deleted? deleted-for-me? bridge-message)
|
|
||||||
[{:type :danger
|
delete-for-me?
|
||||||
|
(conj {:type :danger
|
||||||
:on-press (fn []
|
:on-press (fn []
|
||||||
(rf/dispatch
|
(rf/dispatch [:hide-bottom-sheet])
|
||||||
[:hide-bottom-sheet])
|
|
||||||
(rf/dispatch [:chat.ui/delete-message-for-me message-data
|
(rf/dispatch [:chat.ui/delete-message-for-me message-data
|
||||||
config/delete-message-for-me-undo-time-limit-ms]))
|
config/delete-message-for-me-undo-time-limit-ms]))
|
||||||
|
|
||||||
:label (i18n/label :t/delete-for-me)
|
:label (i18n/label :t/delete-for-me)
|
||||||
:accessibility-label :delete-for-me
|
:accessibility-label :delete-for-me
|
||||||
:icon :i/delete
|
:icon :i/delete
|
||||||
:id :delete-for-me}])
|
:id :delete-for-me})
|
||||||
(when (cond
|
|
||||||
deleted? false
|
delete-for-everyone?
|
||||||
outgoing true
|
(conj {:type :danger
|
||||||
community? can-delete-message-for-everyone?
|
|
||||||
group-chat group-admin?
|
|
||||||
bridge-message false
|
|
||||||
:else false)
|
|
||||||
[{:type :danger
|
|
||||||
:on-press (fn []
|
:on-press (fn []
|
||||||
(rf/dispatch [:hide-bottom-sheet])
|
(rf/dispatch [:hide-bottom-sheet])
|
||||||
(rf/dispatch [:chat.ui/delete-message message-data
|
(rf/dispatch [:chat.ui/delete-message message-data
|
||||||
|
@ -168,7 +184,7 @@
|
||||||
:label (i18n/label :t/delete-for-everyone)
|
:label (i18n/label :t/delete-for-everyone)
|
||||||
:accessibility-label :delete-for-everyone
|
:accessibility-label :delete-for-everyone
|
||||||
:icon :i/delete
|
:icon :i/delete
|
||||||
:id :delete-for-all}])))
|
: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
|
||||||
|
deleted?
|
||||||
|
message-id]} data
|
||||||
actions (get-actions data context)
|
actions (get-actions data context)
|
||||||
main-actions (filter #(= (:type %) :main) actions)
|
{main-actions :main
|
||||||
danger-actions (filter #(= (:type %) :danger) actions)
|
danger-actions :danger
|
||||||
admin-actions (filter #(= (:type %) :admin) actions)]
|
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