[#15836] Images not displayed in chat when received by user with app … (#16256)

This commit is contained in:
flexsurfer 2023-06-13 18:21:33 +02:00 committed by GitHub
parent 65e3b209f2
commit 2932bbea85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 32 deletions

View File

@ -188,4 +188,8 @@
(defn topic-from-url
[url]
(string/lower-case (apply str (map filter-letters-numbers-and-replace-dot-on-dash (url-host url)))))
(string/lower-case (apply str (map filter-letters-numbers-and-replace-dot-on-dash (url-host url)))))
(defn replace-port
[url new-port]
(string/replace url #"(:\d+)" (str ":" new-port)))

View File

@ -10,7 +10,8 @@
[status-im2.contexts.chat.lightbox.animations :as anim]
[status-im2.contexts.chat.lightbox.zoomable-image.constants :as c]
[status-im2.contexts.chat.lightbox.zoomable-image.style :as style]
[status-im2.contexts.chat.lightbox.zoomable-image.utils :as utils]))
[status-im2.contexts.chat.lightbox.zoomable-image.utils :as utils]
[status-im.utils.http :as http]))
(defn tap-gesture
[on-tap]
@ -223,7 +224,7 @@
@set-full-height?
(= curr-orientation orientation/portrait))}
[reanimated/fast-image
{:source {:uri (:image content)}
{:source {:uri (http/replace-port (:image content) (rf/sub [:mediaserver/port]))}
:native-ID (when focused? :shared-element)
:style (style/image dimensions animations (:border-value render-data))}]]]))

View File

@ -7,7 +7,8 @@
[status-im2.constants :as constants]
[status-im2.contexts.chat.messages.content.image.view :as image]
[status-im2.contexts.chat.messages.content.text.view :as text]
[utils.re-frame :as rf]))
[utils.re-frame :as rf]
[status-im.utils.http :as http]))
(def rectangular-style-count 3)
@ -54,7 +55,8 @@
:index index}])}
[fast-image/fast-image
{:style (style/image dimensions index portrait? images-count)
:source {:uri (:image (:content item))}
:source {:uri (http/replace-port (:image (:content item))
(rf/sub [:mediaserver/port]))}
:native-ID (when (and (= shared-element-id (:message-id item))
(< index constants/max-album-photos))
:shared-element)}]

View File

@ -78,16 +78,15 @@
(defn play-pause-player
[{:keys [player-key player-state progress message-id audio-duration-ms seeking-audio?
user-interaction?]
user-interaction? mediaserver-port]
:as params}]
(let [mediaserver-port (rf/sub [:mediaserver/port])
audio-uri (str media-server-uri-prefix
mediaserver-port
audio-path
uri-param
message-id)
player (@active-players player-key)
playing? (= @player-state :playing)]
(let [audio-uri (str media-server-uri-prefix
mediaserver-port
audio-path
uri-param
message-id)
player (@active-players player-key)
playing? (= @player-state :playing)]
(when-not playing?
(reset! current-player-key player-key))
(if (and player
@ -134,18 +133,19 @@
(defn f-audio-message
[player-state progress seeking-audio? {:keys [audio-duration-ms message-id]}
{:keys [in-pinned-view?]}]
(let [player-key (get-player-key message-id in-pinned-view?)
player (@active-players player-key)
duration (if (and player (not (#{:preparing :not-loaded :error} @player-state)))
(audio/get-player-duration player)
audio-duration-ms)
time-secs (quot
(if (or @seeking-audio? (#{:playing :seeking} @player-state))
(if (<= @progress 1) (* duration @progress) @progress)
duration)
1000)
paused? (= (audio/get-state player) audio/PAUSED)
app-state (rf/sub [:app-state])]
(let [player-key (get-player-key message-id in-pinned-view?)
player (@active-players player-key)
duration (if (and player (not (#{:preparing :not-loaded :error} @player-state)))
(audio/get-player-duration player)
audio-duration-ms)
time-secs (quot
(if (or @seeking-audio? (#{:playing :seeking} @player-state))
(if (<= @progress 1) (* duration @progress) @progress)
duration)
1000)
paused? (= (audio/get-state player) audio/PAUSED)
app-state (rf/sub [:app-state])
mediaserver-port (rf/sub [:mediaserver/port])]
(rn/use-effect (fn [] #(destroy-player player-key)))
(rn/use-effect
(fn []
@ -163,8 +163,9 @@
:message-id message-id
:audio-duration-ms duration
:seeking-audio? seeking-audio?
:user-interaction? false})))
[@current-player-key app-state])
:user-interaction? false
:mediaserver-port mediaserver-port})))
[@current-player-key app-state mediaserver-port])
(if (= @player-state :error)
[quo/text
{:style style/error-label
@ -183,7 +184,8 @@
:message-id message-id
:audio-duration-ms duration
:seeking-audio? seeking-audio?
:user-interaction? true})
:user-interaction? true
:mediaserver-port mediaserver-port})
:style (style/play-pause-container)}
[quo/icon
(cond

View File

@ -5,7 +5,8 @@
[react-native.safe-area :as safe-area]
[status-im2.constants :as constants]
[utils.re-frame :as rf]
[status-im2.contexts.chat.messages.content.text.view :as text]))
[status-im2.contexts.chat.messages.content.text.view :as text]
[status-im.utils.http :as http]))
(defn calculate-dimensions
[width height]
@ -17,7 +18,8 @@
[index {:keys [content image-width image-height message-id] :as message} on-long-press]
(let [insets (safe-area/get-insets)
dimensions (calculate-dimensions (or image-width 1000) (or image-height 1000))
shared-element-id (rf/sub [:shared-element-id])]
shared-element-id (rf/sub [:shared-element-id])
image-local-url (http/replace-port (:image content) (rf/sub [:mediaserver/port]))]
[:<>
(when (= index 0)
[rn/view {:style {:margin-bottom 10}} [text/text-content message]])
@ -31,7 +33,7 @@
:index 0
:insets insets}])}
[fast-image/fast-image
{:source {:uri (:image content)}
{:source {:uri image-local-url}
:style (merge dimensions {:border-radius 12})
:native-ID (when (= shared-element-id message-id) :shared-element)
:accessibility-label :image-message}]]]))