[15902] BUGFIX - Resolve public keys into the user's name in the confirmation drawer and image description (#16176)

This commit is contained in:
Ibrahem Khalil 2023-06-27 10:42:01 +03:00 committed by GitHub
parent 86219dbad8
commit 4c8671caa0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 99 additions and 78 deletions

View File

@ -34,9 +34,9 @@
profile-picture name]} context profile-picture name]} context
id (or chat-id public-key) id (or chat-id public-key)
display-name (or display-name (or
name
(when-not group-chat (when-not group-chat
(rf/sub [:contacts/contact-name-by-identity id]))) (rf/sub [:contacts/contact-name-by-identity id]))
name)
contact (when-not group-chat contact (when-not group-chat
(rf/sub [:contacts/contact-by-address (rf/sub [:contacts/contact-by-address
id])) id]))

View File

@ -7,7 +7,7 @@
[utils.re-frame :as rf] [utils.re-frame :as rf]
[status-im2.contexts.chat.lightbox.animations :as anim] [status-im2.contexts.chat.lightbox.animations :as anim]
[status-im2.contexts.chat.lightbox.constants :as c] [status-im2.contexts.chat.lightbox.constants :as c]
[status-im2.constants :as constants])) [status-im2.contexts.chat.messages.content.text.view :as message-view]))
(defn get-small-item-layout (defn get-small-item-layout
[_ index] [_ index]
@ -50,15 +50,17 @@
(defn bottom-view (defn bottom-view
[messages index scroll-index insets animations derived item-width props] [messages index scroll-index insets animations derived item-width props]
(let [text (get-in (first messages) [:content :text]) (let [{:keys [chat-id content]} (first messages)
padding-horizontal (- (/ item-width 2) (/ c/focused-image-size 2))] padding-horizontal (- (/ item-width 2) (/ c/focused-image-size 2))]
[reanimated/linear-gradient [reanimated/linear-gradient
{:colors [:black :transparent] {:colors [:black :transparent]
:start {:x 0 :y 1} :start {:x 0 :y 1}
:end {:x 0 :y 0} :end {:x 0 :y 0}
:style (style/gradient-container insets animations derived)} :style (style/gradient-container insets animations derived)}
(when constants/image-description-in-lightbox? [message-view/render-parsed-text
[rn/text {:style style/text-style} text]) {:content content
:chat-id chat-id
:style-override style/text-style}]
[rn/flat-list [rn/flat-list
{:ref #(reset! (:small-list-ref props) %) {:ref #(reset! (:small-list-ref props) %)
:key-fn :message-id :key-fn :message-id

View File

@ -9,25 +9,41 @@
[utils.re-frame :as rf])) [utils.re-frame :as rf]))
(defn render-inline (defn render-inline
[units {:keys [type literal destination]} chat-id] [units {:keys [type literal destination]} chat-id style-override]
(let [show-as-plain-text? (seq style-override)]
(case (keyword type) (case (keyword type)
:code :code
(conj units [quo/text {:style (merge style/block (style/code)) :weight :code} literal]) (conj units
[quo/text
{:style (if show-as-plain-text?
{:color colors/white}
(merge style/block (style/code)))
:weight :code} literal])
:emph :emph
(conj units [quo/text {:style {:font-style :italic}} literal]) (conj units
[quo/text
{:style {:font-style :italic
:color (when show-as-plain-text? colors/white)}} literal])
:strong :strong
(conj units [quo/text {:weight :bold} literal]) (conj units
[quo/text
(cond-> {:weight :bold}
show-as-plain-text? (assoc :style {:color colors/white})) literal])
:strong-emph :strong-emph
(conj units (conj units
[quo/text [quo/text
{:weight :bold {:weight :bold
:style {:font-style :italic}} literal]) :style {:font-style :italic
:color (when show-as-plain-text? colors/white)}} literal])
:del :del
(conj units [quo/text {:style {:text-decoration-line :line-through}} literal]) (conj units
[quo/text
{:style {:text-decoration-line :line-through
:color (when show-as-plain-text? colors/white)}} literal])
:link :link
(conj units (conj units
@ -71,25 +87,28 @@
"#" "#"
literal])) literal]))
(conj units literal))) (conj units literal))))
(defn render-block (defn render-block
[blocks {:keys [type literal children]} chat-id] [blocks {:keys [type literal children]} chat-id style-override]
(case (keyword type) (case (keyword type)
:paragraph :paragraph
(conj blocks (conj blocks
[rn/view
(reduce (reduce
(fn [acc e] (fn [acc e]
(render-inline acc e chat-id)) (render-inline acc e chat-id style-override))
[quo/text {:size :paragraph-1}] [quo/text
children)) {:style {:size :paragraph-1
:color (when (seq style-override) colors/white)}}]
children)])
:edited-block :edited-block
(conj blocks (conj blocks
(reduce (reduce
(fn [acc e] (fn [acc e]
(render-inline acc e chat-id)) (render-inline acc e chat-id style-override))
[quo/text {:size :paragraph-1}] [quo/text {:size :paragraph-1}]
children)) children))
@ -120,11 +139,11 @@
(conj parsed-text {:type :edited-block :children [edited-tag]})))) (conj parsed-text {:type :edited-block :children [edited-tag]}))))
(defn render-parsed-text (defn render-parsed-text
[{:keys [content chat-id edited-at]}] [{:keys [content chat-id edited-at style-override]}]
^{:key (:parsed-text content)} ^{:key (:parsed-text content)}
[rn/view [rn/view {:style style-override}
(reduce (fn [acc e] (reduce (fn [acc e]
(render-block acc e chat-id)) (render-block acc e chat-id style-override))
[:<>] [:<>]
(cond-> (:parsed-text content) (cond-> (:parsed-text content)
edited-at edited-at