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

View File

@ -7,7 +7,8 @@
[status-im2.constants :as constants] [status-im2.constants :as constants]
[status-im2.contexts.chat.messages.content.image.view :as image] [status-im2.contexts.chat.messages.content.image.view :as image]
[status-im2.contexts.chat.messages.content.text.view :as text] [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) (def rectangular-style-count 3)
@ -54,7 +55,8 @@
:index index}])} :index index}])}
[fast-image/fast-image [fast-image/fast-image
{:style (style/image dimensions index portrait? images-count) {: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)) :native-ID (when (and (= shared-element-id (:message-id item))
(< index constants/max-album-photos)) (< index constants/max-album-photos))
:shared-element)}] :shared-element)}]

View File

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

View File

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