Skip to content

Commit 6ff1569

Browse files
committed
image size
1 parent 4e48ac8 commit 6ff1569

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/status_im/ui/screens/chat/message/message.cljs

+10-7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
[status-im.ui.screens.chat.message.reactions :as reactions]
2020
[status-im.ui.screens.chat.image.preview.views :as preview]
2121
[quo.core :as quo]
22+
[taoensso.timbre :as log]
2223
[status-im.utils.config :as config]
2324
[reagent.core :as reagent]
2425
[status-im.ui.screens.chat.components.reply :as components.reply]
@@ -341,20 +342,21 @@
341342
(def image-max-height 192)
342343

343344
(defn image-set-size [dimensions]
344-
(fn [width height]
345-
(when (< width height)
346-
;; if width less than the height we reduce width proportionally to height
347-
(let [k (/ height image-max-height)]
348-
(when (not= (/ width k) (first @dimensions))
349-
(reset! dimensions [(/ width k) image-max-height]))))))
345+
(fn [evt]
346+
(let [width (.-width (.-nativeEvent evt))
347+
height (.-height (.-nativeEvent evt))]
348+
(when (< width height)
349+
;; if width less than the height we reduce width proportionally to height
350+
(let [k (/ height image-max-height)]
351+
(when (not= (/ width k) (first @dimensions))
352+
(reset! dimensions [(/ width k) image-max-height])))))))
350353

351354
(defn message-content-image
352355
[{:keys [content outgoing in-popover?] :as message}
353356
{:keys [on-long-press]}]
354357
(let [dimensions (reagent/atom [image-max-width image-max-height])
355358
visible (reagent/atom false)
356359
uri (:image content)]
357-
(react/image-get-size uri (image-set-size dimensions))
358360
(fn []
359361
(let [style-opts {:outgoing outgoing
360362
:width (first @dimensions)
@@ -372,6 +374,7 @@
372374
[react/view {:style (style/image-message style-opts)
373375
:accessibility-label :image-message}
374376
[react/fast-image {:style (dissoc style-opts :outgoing)
377+
:on-load (image-set-size dimensions)
375378
:source {:uri uri}}
376379
[react/view {:style (style/image-message-border style-opts)}]]]]]))))
377380

status-go-version.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"owner": "status-im",
55
"repo": "status-go",
66
"version": "experiment/run-http-image-server-2",
7-
"commit-sha1": "5ae5f5d4d8f43f7cec6075dd8343718bff878ae4",
8-
"src-sha256": "1m3wsn57j5l5fi2rql4a4bsgm9b0spb3h1fns5krdsnmjpiv5sxl"
7+
"commit-sha1": "e035a62b7ef8c82b99b317e4bfe638c794c38a44",
8+
"src-sha256": "1zzq68fy2s179f5h125lmaxrkx98fjgwyrn4qfgnayksky8b2kgm"
99
}

0 commit comments

Comments
 (0)