From d27ab756d031c79e5aa11bc234351712f8316278 Mon Sep 17 00:00:00 2001 From: John Ngei Date: Fri, 26 Jul 2024 21:14:04 +0200 Subject: [PATCH] fix_:display group message using the new ui (#20787) --- .../messages/system_message/style.cljs | 3 +- .../messages/system_message/view.cljs | 9 ++++ .../messenger/messages/content/style.cljs | 4 ++ .../chat/messenger/messages/content/view.cljs | 48 ++++++++++++++++++- 4 files changed, 61 insertions(+), 3 deletions(-) diff --git a/src/quo/components/messages/system_message/style.cljs b/src/quo/components/messages/system_message/style.cljs index 54b404ebb4..0e760a37ff 100644 --- a/src/quo/components/messages/system_message/style.cljs +++ b/src/quo/components/messages/system_message/style.cljs @@ -32,8 +32,7 @@ (def system-message-base-wrapper {:flex-direction :row - :flex 1 - :align-items :center}) + :flex 1}) (def system-message-base-content-wrapper {:align-self :center diff --git a/src/quo/components/messages/system_message/view.cljs b/src/quo/components/messages/system_message/view.cljs index 9ee41eb0ff..082fc16d74 100644 --- a/src/quo/components/messages/system_message/view.cljs +++ b/src/quo/components/messages/system_message/view.cljs @@ -127,6 +127,14 @@ (when incoming? [split-text "sent you a contact request" theme true]) [sm-timestamp timestamp theme]]])) +(defn system-message-group + [{:keys [customization-color child]}] + [system-message-base + {:icon {:icon :i/add-user + :color (or customization-color :primary) + :opacity 5}} + [rn/view child]]) + (defn system-message-pinned [{:keys [pinned-by child customization-color timestamp]}] (let [theme (quo.theme/use-theme)] @@ -183,6 +191,7 @@ :contact-request [system-message-contact-request data] :added [system-message-added data] :removed [system-message-removed data] + :group [system-message-group data] nil)])) (defn system-message diff --git a/src/status_im/contexts/chat/messenger/messages/content/style.cljs b/src/status_im/contexts/chat/messenger/messages/content/style.cljs index 6bfc162d44..82e7f982a1 100644 --- a/src/status_im/contexts/chat/messenger/messages/content/style.cljs +++ b/src/status_im/contexts/chat/messenger/messages/content/style.cljs @@ -33,3 +33,7 @@ (def drawer-message-container {:padding-top 4 :padding-bottom 4}) + +(def group-member-mention + {:flex-direction :row + :align-items :center}) diff --git a/src/status_im/contexts/chat/messenger/messages/content/view.cljs b/src/status_im/contexts/chat/messenger/messages/content/view.cljs index 43b700064d..121f9a80c0 100644 --- a/src/status_im/contexts/chat/messenger/messages/content/view.cljs +++ b/src/status_im/contexts/chat/messenger/messages/content/view.cljs @@ -126,14 +126,60 @@ :photo-path photo-path :incoming? (not= public-key from)}])) +(defn group-member + [literal] + (let [[primary-name _] (rf/sub [:contacts/contact-two-names-by-identity literal]) + photo-path (rf/sub [:chats/photo-path literal])] + [rn/view {:style style/group-member-mention} + [quo/user-avatar + {:full-name primary-name + :profile-picture photo-path + :status-indicator? false + :size :xxxs + :ring? false}] + [quo/text + {:weight :semi-bold + :style {:margin-left 4}} + primary-name]])) + + +(defn resolve-group-system-message + [{:keys [children]}] + (reduce (fn [acc {:keys [type literal]}] + (if (= type "mention") + (conj acc [group-member literal]) + (conj acc + [rn/view + [quo/text literal]]))) + [:<>] + children)) + + +(defn render-parsed-text + [content] + (reduce (fn [acc e] + (conj acc (resolve-group-system-message e))) + [quo/text] + (:parsed-text content))) + +(defn group-system-message + [{:keys [chat-id timestamp-str content]} type] + (let [{:keys [customization-color]} (rf/sub [:contacts/contact-by-address chat-id])] + [quo/system-message + {:type type + :timestamp timestamp-str + :customization-color customization-color + :child (render-parsed-text content)}])) + (defn system-message-content [{:keys [content-type quoted-message] :as message-data}] + (if quoted-message [pin/pinned-message message-data] (condp = content-type constants/content-type-system-text - [system.text/text-content message-data] + [group-system-message message-data :group] constants/content-type-system-pinned-message [system.text/text-content message-data]