[17377-17378] Fix reply view in activity center showing only one phot… (#17388)

This commit is contained in:
Ibrahem Khalil 2023-09-26 15:59:36 +03:00 committed by GitHub
parent baf3fb9bbd
commit da5086aae2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 76 additions and 40 deletions

View File

@ -26,11 +26,15 @@
{:color colors/white}) {:color colors/white})
(defn message-container (defn message-container
[attachment] [attachment text-with-photos?]
{:border-radius 12 {:border-radius 12
:margin-top 10 :margin-top 10
:padding-horizontal 12 :padding-horizontal 12
:padding-vertical (if (#{:photo :gif} attachment) 12 8) :padding-vertical (if (and
(not text-with-photos?)
(#{:photo :gif} attachment))
12
8)
:background-color colors/white-opa-5}) :background-color colors/white-opa-5})
(def footer-container (def footer-container

View File

@ -73,24 +73,33 @@
detail]])) detail]]))
context)))) context))))
(defn- hiccup-props
[body]
(and (vector? body)
(map? (second body))
(second body)))
(defn- activity-message (defn- activity-message
[{:keys [title body title-number-of-lines body-number-of-lines attachment]}] [{:keys [title body title-number-of-lines body-number-of-lines attachment]}]
[rn/view {:style (style/message-container attachment)} (let [{:keys [photos message-text]} (hiccup-props body)
(when title text-with-photos? (and (not (string/blank? message-text))
[text/text (seq photos))]
{:size :paragraph-2 [rn/view {:style (style/message-container attachment text-with-photos?)}
:accessibility-label :activity-message-title (when title
:style style/message-title [text/text
:number-of-lines title-number-of-lines} {:size :paragraph-2
title]) :accessibility-label :activity-message-title
(if (string? body) :style style/message-title
[text/text :number-of-lines title-number-of-lines}
{:style style/message-body title])
:accessibility-label :activity-message-body (if (string? body)
:size :paragraph-1 [text/text
:number-of-lines body-number-of-lines} {:style style/message-body
body] :accessibility-label :activity-message-body
body)]) :size :paragraph-1
:number-of-lines body-number-of-lines}
body]
body)]))
(defn- activity-title (defn- activity-title
[title replying?] [title replying?]

View File

@ -1,5 +1,7 @@
(ns quo2.components.notifications.activity-logs-photos.style) (ns quo2.components.notifications.activity-logs-photos.style)
(def text {:margin-bottom 8})
(def photos-container (def photos-container
{:flex 1 {:flex 1
:height 40 :height 40

View File

@ -1,14 +1,25 @@
(ns quo2.components.notifications.activity-logs-photos.view (ns quo2.components.notifications.activity-logs-photos.view
(:require [react-native.core :as rn] (:require [react-native.core :as rn]
[quo2.components.notifications.activity-logs-photos.style :as style])) [quo2.components.markdown.text :as text]
[quo2.components.notifications.activity-logs-photos.style :as style]
[clojure.string :as string]))
(defn view (defn view
[{:keys [photos]}] [{:keys [photos message-text]}]
[rn/view {:style style/photos-container} [:<>
(map-indexed (when (not (string/blank? message-text))
(fn [index photo] [text/text
^{:key index} {:size :paragraph-1
[rn/image :weight :regular
{:source photo :style style/text
:style (style/photo index)}]) :number-of-lines 2
photos)]) :accessibility-label :activity-log-title}
message-text])
[rn/view {:style style/photos-container}
(map-indexed
(fn [index photo]
^{:key index}
[rn/image
{:source photo
:style (style/photo index)}])
photos)]])

View File

@ -61,7 +61,8 @@
:chatId :chat-id :chatId :chat-id
:contactVerificationStatus :contact-verification-status :contactVerificationStatus :contact-verification-status
:communityId :community-id :communityId :community-id
:membershipStatus :membership-status}) :membershipStatus :membership-status
:albumMessages :album-messages})
(update :last-message #(when % (messages/<-rpc %))) (update :last-message #(when % (messages/<-rpc %)))
(update :message #(when % (messages/<-rpc %))) (update :message #(when % (messages/<-rpc %)))
(update :reply-message #(when % (messages/<-rpc %))) (update :reply-message #(when % (messages/<-rpc %)))

View File

@ -14,16 +14,22 @@
;; NOTE: Replies support text, image and stickers only. ;; NOTE: Replies support text, image and stickers only.
(defn- get-message-content (defn- get-message-content
[{:keys [content-type] :as message}] [{:keys [content-type] :as message} album-messages media-server-port]
(case content-type (case content-type
constants/content-type-text [quo/text {:style style/tag-text} constants/content-type-text [quo/text {:style style/tag-text}
(get-in message [:content :text])] (get-in message [:content :text])]
constants/content-type-image constants/content-type-image
(let [image (get-in message [:content :image]) (let [images (or album-messages message)
image-local-url (url/replace-port image (rf/sub [:mediaserver/port])) image-urls (if album-messages
photos (when image-local-url [{:uri image-local-url}])] (map :image images)
[quo/activity-logs-photos {:photos photos}]) [(get-in message [:content :image])])
image-local-urls (map (fn [url]
{:uri (url/replace-port url media-server-port)})
image-urls)]
[quo/activity-logs-photos
{:photos image-local-urls
:message-text (get-in message [:content :text])}])
constants/content-type-sticker [old-message/sticker message] constants/content-type-sticker [old-message/sticker message]
@ -54,11 +60,12 @@
(defn view (defn view
[{:keys [notification set-swipeable-height customization-color] :as props}] [{:keys [notification set-swipeable-height customization-color] :as props}]
(let [{:keys [author chat-name community-id chat-id (let [{:keys [author chat-name community-id chat-id
message read timestamp]} notification message read timestamp album-messages]} notification
community-chat? (not (string/blank? community-id)) community-chat? (not (string/blank? community-id))
community (rf/sub [:communities/community community-id]) community (rf/sub [:communities/community community-id])
community-name (:name community) community-name (:name community)
community-image (get-in community [:images :thumbnail :uri])] community-image (get-in community [:images :thumbnail :uri])
media-server-port (rf/sub [:mediaserver/port])]
[swipeable props [swipeable props
[gesture/touchable-without-feedback [gesture/touchable-without-feedback
{:on-press (fn [] {:on-press (fn []
@ -106,4 +113,6 @@
:else :else
nil) nil)
:body (get-message-content message)}}]]])) :body (get-message-content message
album-messages
media-server-port)}}]]]))