Improvements and bump go

This commit is contained in:
Ibrkhalil
2024-03-08 14:43:13 +02:00
parent cfa893c746
commit 109ab6b2ff
6 changed files with 40 additions and 14 deletions
@@ -1,9 +1,15 @@
(ns quo.components.links.link-preview.view
(:require
["react-native-blob-util" :default ReactNativeBlobUtil]
[oops.core :as oops]
[quo.components.buttons.button.view :as button]
[quo.components.links.link-preview.style :as style]
[quo.components.markdown.text :as text]
[react-native.core :as rn]))
[react-native.core :as rn]
[react-native.platform :as platform]
[react-native.svg :as svg]
[reagent.core :as reagent]
[taoensso.timbre :as log]))
(defn- button-disabled
[disabled-text on-enable]
@@ -53,12 +59,26 @@
(defn- logo-comp
[logo]
[rn/image
{:accessibility-label :logo
:source (if (string? logo)
{:uri logo}
logo)
:style style/logo}])
(let [xml-data (reagent/atom nil)
is-svg? (reagent/atom nil)
on-success (fn [xml-string]
(reset! xml-data xml-string))
_get-svg (-> (.config ReactNativeBlobUtil (clj->js {:trusty platform/ios?}))
(.fetch "GET" logo)
(.then #(do
(reset! is-svg? (= "image/svg"
(oops/oget % ["respInfo" "headers" "Content-Type"])))
(on-success (oops/oget % "data"))))
(.catch #(log/error "could not fetch favicon " logo)))]
(fn []
(if @is-svg?
[svg/svg-xml (merge style/logo {:xml @xml-data})]
[rn/image
{:accessibility-label :logo
:source (if (string? logo)
{:uri logo}
logo)
:style style/logo}]))))
(defn view
[{:keys [title logo description link thumbnail
@@ -6,12 +6,15 @@
[quo.components.markdown.text :as text]
[quo.foundations.colors :as colors]
[react-native.core :as rn]
[react-native.svg :as svg]))
[react-native.svg :as svg]
[status-im.constants :as constants]))
(defn- logo-comp
[{:keys [logo]}]
(if (string/starts-with? logo "<svg")
[svg/svg-xml (merge style/logo {:xml logo})]
(if (string/starts-with? logo constants/base64-svg-prefix)
[svg/svg-xml (merge style/logo {:xml (-> logo
(string/replace constants/base64-svg-prefix "")
js/atob)})]
[rn/image
{:accessibility-label :logo
:source (if (string? logo)
+2
View File
@@ -366,6 +366,8 @@
"We prefix our keys with 0xe701 prior to serialisation them"
"0xe701")
(def base64-svg-prefix "data:image/svg;base64,")
(def ^:const theme-type-system 0)
(def ^:const theme-type-light 1)
(def ^:const theme-type-dark 2)
@@ -159,7 +159,7 @@
(->> link-previews
(map #(select-keys %
[:url :title :description :thumbnail
:status-link-preview?]))
:status-link-preview? :favicon]))
(filter (fn [preview]
(not (:status-link-preview? preview))))))
@@ -16,12 +16,13 @@
(let [previews (rf/sub [:chats/message-link-previews chat-id message-id])]
(when (seq previews)
[:<>
(for [{:keys [url title description thumbnail hostname]} previews]
(for [{:keys [url title description thumbnail hostname favicon]} previews]
^{:key url}
[quo/link-preview
{:title title
:description description
:link hostname
:logo favicon
:thumbnail (:url thumbnail)
:thumbnail-size (when (nearly-square? thumbnail) :large)
:container-style {:margin-top 8}}])])))
+2 -2
View File
@@ -4,6 +4,6 @@
"owner": "status-im",
"repo": "status-go",
"version": "add-favicons-to-link-previews",
"commit-sha1": "55b2907a722f872dd21c42198a25be927a22e03d",
"src-sha256": "0ll52y37rvc3j6w3bdvfnhjw9sgfsp0m5wc26j428pb2xgipr6jd"
"commit-sha1": "b5d40d654f5eae3ad7cd6269a7a69a8e24415819",
"src-sha256": "1i9maz8dzfvjczlw0a66ch7112hiism4nrvb6z420rbxcjnk9pad"
}