Measuring the proper sizes of images in chat (#15675)
* Measuring the proper sizes of images * Style fix
This commit is contained in:
parent
4fefa629fc
commit
a0f2481406
|
@ -89,6 +89,8 @@
|
|||
|
||||
(defn link-preview-loader
|
||||
[link _]
|
||||
(let [measured-width (reagent/atom 0)
|
||||
measured-height (reagent/atom 0)]
|
||||
(reagent/create-class
|
||||
{:component-did-mount
|
||||
(fn []
|
||||
|
@ -102,7 +104,7 @@
|
|||
:reagent-render
|
||||
(fn [link {:keys [on-long-press]}]
|
||||
(let [cached-preview-data (rf/sub [:link-preview/cache link])]
|
||||
(when-let [{:keys [site title thumbnail-url error] :as preview-data} cached-preview-data]
|
||||
(when-let [{:keys [site title thumbnail-url error]} cached-preview-data]
|
||||
(when (and (not error) site title)
|
||||
[rn/touchable-opacity
|
||||
{:style (when-not (is-gif? thumbnail-url)
|
||||
|
@ -126,8 +128,15 @@
|
|||
[rn/view (style/separator)]
|
||||
[fast-image/fast-image
|
||||
{:source {:uri thumbnail-url}
|
||||
:style (style/image (select-keys preview-data [:height :width]))
|
||||
:accessibility-label :member-photo}]])]]))))}))
|
||||
:on-load (fn [e]
|
||||
(let [{:keys [width height]} (js->clj (.-nativeEvent e)
|
||||
:keywordize-keys
|
||||
true)]
|
||||
(reset! measured-width width)
|
||||
(reset! measured-height height)))
|
||||
:style (style/image {:width @measured-width
|
||||
:height @measured-height})
|
||||
:accessibility-label :member-photo}]])]]))))})))
|
||||
|
||||
(defn link-preview-enable-request
|
||||
[]
|
||||
|
|
Loading…
Reference in New Issue