fix_:display group message using the new ui (#20787)

This commit is contained in:
John Ngei 2024-07-26 21:14:04 +02:00 committed by GitHub
parent c6a1db6334
commit d27ab756d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 61 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -33,3 +33,7 @@
(def drawer-message-container
{:padding-top 4
:padding-bottom 4})
(def group-member-mention
{:flex-direction :row
:align-items :center})

View File

@ -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]