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
|
(defn link-preview-loader
|
||||||
[link _]
|
[link _]
|
||||||
|
(let [measured-width (reagent/atom 0)
|
||||||
|
measured-height (reagent/atom 0)]
|
||||||
(reagent/create-class
|
(reagent/create-class
|
||||||
{:component-did-mount
|
{:component-did-mount
|
||||||
(fn []
|
(fn []
|
||||||
|
@ -102,7 +104,7 @@
|
||||||
:reagent-render
|
:reagent-render
|
||||||
(fn [link {:keys [on-long-press]}]
|
(fn [link {:keys [on-long-press]}]
|
||||||
(let [cached-preview-data (rf/sub [:link-preview/cache link])]
|
(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)
|
(when (and (not error) site title)
|
||||||
[rn/touchable-opacity
|
[rn/touchable-opacity
|
||||||
{:style (when-not (is-gif? thumbnail-url)
|
{:style (when-not (is-gif? thumbnail-url)
|
||||||
|
@ -126,8 +128,15 @@
|
||||||
[rn/view (style/separator)]
|
[rn/view (style/separator)]
|
||||||
[fast-image/fast-image
|
[fast-image/fast-image
|
||||||
{:source {:uri thumbnail-url}
|
{:source {:uri thumbnail-url}
|
||||||
:style (style/image (select-keys preview-data [:height :width]))
|
:on-load (fn [e]
|
||||||
:accessibility-label :member-photo}]])]]))))}))
|
(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
|
(defn link-preview-enable-request
|
||||||
[]
|
[]
|
||||||
|
|
Loading…
Reference in New Issue