move status-im from utils (#18249)
This commit is contained in:
parent
5ec5838657
commit
ad8d537b9c
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
INVALID_CHANGES=$(grep -E -r '(re-frame/dispatch|rf/dispatch|re-frame/subscribe|rf/subscribe|rf/sub|<sub|>evt|status-im\.|status-im2\.)' --include '*.cljs' --include '*.clj' './src/quo')
|
||||
INVALID_CHANGES=$(grep -E -r '(re-frame/dispatch|rf/dispatch|re-frame/subscribe|rf/subscribe|rf/sub|<sub|>evt|status-im\.)' --include '*.cljs' --include '*.clj' './src/quo')
|
||||
|
||||
if test -n "$INVALID_CHANGES"; then
|
||||
echo "WARNING: re-frame, status-im are not allowed in quo components"
|
||||
|
@ -8,3 +8,21 @@ if test -n "$INVALID_CHANGES"; then
|
|||
echo "$INVALID_CHANGES"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
INVALID_CHANGES2=$(grep -E -r '(status-im\.)' --include '*.cljs' --include '*.clj' './src/utils')
|
||||
|
||||
if test -n "$INVALID_CHANGES2"; then
|
||||
echo "WARNING: status-im are not allowed in utils package"
|
||||
echo ''
|
||||
echo "$INVALID_CHANGES2"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
INVALID_CHANGES3=$(grep -E -r '(status-im\.)' --include '*.cljs' --include '*.clj' './src/react_native')
|
||||
|
||||
if test -n "$INVALID_CHANGES3"; then
|
||||
echo "WARNING: status-im are not allowed in react-native package"
|
||||
echo ''
|
||||
echo "$INVALID_CHANGES3"
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
[native-module.core :as native-module]
|
||||
[re-frame.core :as re-frame]
|
||||
[react-native.platform :as platform]
|
||||
[status-im.common.universal-links :as links]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.contexts.chat.events :as chat.events]
|
||||
[status-im.navigation.events :as navigation]
|
||||
|
@ -27,7 +28,6 @@
|
|||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]
|
||||
[utils.security.core :as security]
|
||||
[utils.universal-links :as links]
|
||||
[utils.url :as url]))
|
||||
|
||||
(rf/defn update-browser-option
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
[legacy.status-im.wallet.utils :as wallet.utils]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.common.router :as router]
|
||||
[status-im.common.universal-links :as links]
|
||||
[status-im.navigation.events :as navigation]
|
||||
[utils.ethereum.chain :as chain]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.money :as money]
|
||||
[utils.re-frame :as rf]
|
||||
[utils.universal-links :as links]
|
||||
[utils.url :as url]))
|
||||
|
||||
;; FIXME(Ferossgp): Should be part of QR scanner not wallet
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
(ns status-im.common.font.effects
|
||||
(:require
|
||||
[react-native.platform :as platform]
|
||||
[status-im.constants :as constants]
|
||||
utils.image-server
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(rf/reg-fx :effects.font/get-font-file-for-initials-avatar
|
||||
(fn [callback]
|
||||
(utils.image-server/get-font-file-ready callback)))
|
||||
(utils.image-server/get-font-file-ready
|
||||
(if platform/ios?
|
||||
(:ios constants/initials-avatar-font-conf)
|
||||
(:android constants/initials-avatar-font-conf))
|
||||
callback)))
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
[legacy.status-im.ethereum.ens :as ens]
|
||||
[native-module.core :as native-module]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.common.validators :as validators]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.contexts.chat.events :as chat.events]
|
||||
[taoensso.timbre :as log]
|
||||
|
@ -15,8 +16,7 @@
|
|||
[utils.ethereum.eip.eip681 :as eip681]
|
||||
[utils.security.core :as security]
|
||||
[utils.transforms :as transforms]
|
||||
[utils.url :as url]
|
||||
[utils.validators :as validators]))
|
||||
[utils.url :as url]))
|
||||
|
||||
(def ethereum-scheme "ethereum:")
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
(ns status-im.common.universal-links
|
||||
(:require
|
||||
[clojure.string :as string]
|
||||
[goog.string :as gstring]
|
||||
[native-module.core :as native-module]
|
||||
[re-frame.core :as re-frame]
|
||||
[react-native.async-storage :as async-storage]
|
||||
[react-native.core :as rn]
|
||||
[schema.core :as schema]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.navigation.events :as navigation]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.ethereum.chain :as chain]
|
||||
|
@ -17,6 +19,27 @@
|
|||
{:external "https://status.app"
|
||||
:internal "status-app:/"})
|
||||
|
||||
(def links
|
||||
{:private-chat "%s/p/%s"
|
||||
:user "%s/u#%s"
|
||||
:browse "%s/b/%s"})
|
||||
|
||||
(defn universal-link?
|
||||
[url]
|
||||
(boolean
|
||||
(re-matches constants/regx-universal-link url)))
|
||||
|
||||
(defn deep-link?
|
||||
[url]
|
||||
(boolean
|
||||
(re-matches constants/regx-deep-link url)))
|
||||
|
||||
(defn generate-link
|
||||
[link-type domain-type param]
|
||||
(gstring/format (get links link-type)
|
||||
(get domains domain-type)
|
||||
param))
|
||||
|
||||
(rf/defn handle-browse
|
||||
[_ {:keys [url]}]
|
||||
(log/info "universal-links: handling browse" url)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
(ns status-im.common.universal-links-test
|
||||
(:require
|
||||
[cljs.test :refer-macros [deftest is are testing]]
|
||||
matcher-combinators.test
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.common.universal-links :as links]))
|
||||
|
||||
|
@ -98,3 +99,51 @@
|
|||
db {:profile/profile {:public-key pubkey}}
|
||||
rst (links/save-profile-url {:db db} ["invalid pubkey"])]
|
||||
(is (nil? rst))))))
|
||||
|
||||
(deftest universal-link-test
|
||||
(testing "universal-link?"
|
||||
(are [l rst] (match? (links/universal-link? l) rst)
|
||||
"status-app://blah"
|
||||
false
|
||||
"http://status.app/blah"
|
||||
false
|
||||
"http://status.app/c#zQ3shPyZJnxZK4Bwyx9QsaksNKDYTPmpwPvGSjMYVHoXHeEgB"
|
||||
true
|
||||
"http://status.app/u#zQ3shPyZJnxZK4Bwyx9QsaksNKDYTPmpwPvGSjMYVHoXHeEgB"
|
||||
true
|
||||
"https://status.app/u/Ow==#zQ3shsKnV5HJMWJR61c6dssWzHszdbLfBoMF1gcLtSQAYdw2d"
|
||||
true
|
||||
"https://status.app/c/Ow==#zQ3shYSHp7GoiXaauJMnDcjwU2yNjdzpXLosAWapPS4CFxc11"
|
||||
true
|
||||
"https://status.app/c/Ow==#zQ3shYSHp7GoiXaauJMnDcjwU2yNjdzpXLosAWapPS4CFxc111"
|
||||
false
|
||||
"https://status.app/u/G10A4B0JdgwyRww90WXtnP1oNH1ZLQNM0yX0Ja9YyAMjrqSZIYINOHCbFhrnKRAcPGStPxCMJDSZlGCKzmZrJcimHY8BbcXlORrElv_BbQEegnMDPx1g9C5VVNl0fE4y#zQ3shwQPhRuDJSjVGVBnTjCdgXy5i9WQaeVPdGJD6yTarJQSj"
|
||||
true
|
||||
"https://status.app/c/G00AAGS9TbI9mSR-ZNmFrhRjNuEeXAAbcAIUaLLJyjMOG3ACJQ12oIHD78QhzO9s_T5bUeU7rnATWJg3mGgTUemrAg==#zQ3shYf5SquxkiY3FmCW6Nz2wuFWFcM6JEdUD62ApjAvE5YPv"
|
||||
true
|
||||
"http://status.app/c#zQ3shPyZJnxZK4Bwyx9QsaksNKDYTPmpwPvGSjMYVHoXHeEgBhttp://status.app/c#zQ3shPyZJnxZK4Bwyx9QsaksNKDYTPmpwPvGSjMYVHoXHeEgB"
|
||||
false
|
||||
"http://status.app/u#zQ3shPyZJnxZK4Bwyx9QsaksNKDYTPmpwPvGSjMYVHoXHeEgBhttp://status.app/u#zQ3shPyZJnxZK4Bwyx9QsaksNKDYTPmpwPvGSjMYVHoXHeEgB"
|
||||
false
|
||||
"https://status.app/u/Ow==#zQ3shsKnV5HJMWJR61c6dssWzHszdbLfBoMF1gcLtSQAYdw2dhttps://status.app/u/Ow==#zQ3shsKnV5HJMWJR61c6dssWzHszdbLfBoMF1gcLtSQAYdw2d"
|
||||
false
|
||||
"https://status.app/c/Ow==#zQ3shYSHp7GoiXaauJMnDcjwU2yNjdzpXLosAWapPS4CFxc11https://status.app/c/Ow==#zQ3shYSHp7GoiXaauJMnDcjwU2yNjdzpXLosAWapPS4CFxc11"
|
||||
false
|
||||
"https://status.app/u/G10A4B0JdgwyRww90WXtnP1oNH1ZLQNM0yX0Ja9YyAMjrqSZIYINOHCbFhrnKRAcPGStPxCMJDSZlGCKzmZrJcimHY8BbcXlORrElv_BbQEegnMDPx1g9C5VVNl0fE4y#zQ3shwQPhRuDJSjVGVBnTjCdgXy5i9WQaeVPdGJD6yTarJQSjhttps://status.app/u/G10A4B0JdgwyRww90WXtnP1oNH1ZLQNM0yX0Ja9YyAMjrqSZIYINOHCbFhrnKRAcPGStPxCMJDSZlGCKzmZrJcimHY8BbcXlORrElv_BbQEegnMDPx1g9C5VVNl0fE4y#zQ3shwQPhRuDJSjVGVBnTjCdgXy5i9WQaeVPdGJD6yTarJQSj"
|
||||
false
|
||||
"https://status.app/c/Ow==#zQ3shbmfT3hvh4mKa1v6uAjjyztQEroh8Mfn6Ckegjd7LT3XKhttps://status.app/c#zQ3shbmfT3hvh4mKa1v6uAjjyztQEroh8Mfn6Ckegjd7LT3XK"
|
||||
false
|
||||
"https://status.app/blah"
|
||||
false
|
||||
"https://status.app/browse/www.аррӏе.com"
|
||||
false
|
||||
"https://not.status.im/blah"
|
||||
false
|
||||
"http://not.status.im/blah"
|
||||
false))
|
||||
|
||||
(testing "deep-link?"
|
||||
(are [l rst] (match? (links/deep-link? l) rst)
|
||||
"status-app://blah" true
|
||||
"http://status.app/blah" false
|
||||
"ethereum:0x89205a3a3b2a69de6dbf7f01ed13b2108b2c43e7" true)))
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
(ns utils.validators
|
||||
(ns status-im.common.validators
|
||||
(:require
|
||||
[status-im.constants :as constants]))
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
(ns utils.validators-test
|
||||
(ns status-im.common.validators-test
|
||||
(:require
|
||||
[cljs.test :refer-macros [deftest testing is]]
|
||||
[utils.validators :refer [valid-compressed-key?]]))
|
||||
[status-im.common.validators :refer [valid-compressed-key?]]))
|
||||
|
||||
(deftest test-valid-compressed-key
|
||||
(testing "valid"
|
|
@ -1,14 +1,14 @@
|
|||
(ns status-im.contexts.add-new-contact.events
|
||||
(:require
|
||||
[clojure.string :as string]
|
||||
[status-im.common.validators :as validators]
|
||||
status-im.contexts.add-new-contact.effects
|
||||
[status-im.contexts.contacts.events :as data-store.contacts]
|
||||
[status-im.navigation.events :as navigation]
|
||||
[utils.ens.stateofus :as stateofus]
|
||||
[utils.ethereum.chain :as chain]
|
||||
[utils.re-frame :as rf]
|
||||
[utils.string :as utils.string]
|
||||
[utils.validators :as validators]))
|
||||
[utils.string :as utils.string]))
|
||||
|
||||
(defn init-contact
|
||||
"Create a new contact (persisted to app-db as [:contacts/new-identity]).
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
[legacy.status-im.ui.screens.profile.visibility-status.utils :as visibility-status-utils]
|
||||
[quo.theme :as theme]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.common.pixel-ratio :as pixel-ratio]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.contexts.profile.utils :as profile.utils]
|
||||
[utils.address :as address]
|
||||
|
@ -41,13 +42,19 @@
|
|||
clock (:clock image)
|
||||
uri (image-server/get-contact-image-uri-fn
|
||||
{:port port
|
||||
:public-key public-key
|
||||
:image-name image-name
|
||||
:ratio pixel-ratio/ratio
|
||||
:public-key
|
||||
public-key
|
||||
:image-name
|
||||
image-name
|
||||
; We pass the clock so that we reload the
|
||||
; image if the image is updated
|
||||
:clock clock
|
||||
:theme theme
|
||||
:override-ring? (when ens-name false)})]
|
||||
:clock
|
||||
clock
|
||||
:theme
|
||||
theme
|
||||
:override-ring?
|
||||
(when ens-name false)})]
|
||||
(assoc-in acc [(keyword image-name) :fn] uri)))
|
||||
images
|
||||
(vals images))
|
||||
|
@ -57,8 +64,10 @@
|
|||
{:thumbnail
|
||||
{:fn (image-server/get-initials-avatar-uri-fn
|
||||
{:port port
|
||||
:ratio pixel-ratio/ratio
|
||||
:public-key public-key
|
||||
:override-ring? (when ens-name false)
|
||||
:uppercase-ratio (:uppercase-ratio constants/initials-avatar-font-conf)
|
||||
:theme theme
|
||||
:font-file font-file})}})]
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
[legacy.status-im.wallet.utils :as wallet.utils]
|
||||
[quo.theme :as theme]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.common.pixel-ratio :as pixel-ratio]
|
||||
[status-im.constants :as constants]
|
||||
[utils.address :as address]
|
||||
[utils.image-server :as image-server]
|
||||
|
@ -40,12 +41,18 @@
|
|||
{:fn
|
||||
(if profile-pic
|
||||
(image-server/get-account-image-uri-fn {:port port
|
||||
:ratio pixel-ratio/ratio
|
||||
:image-name profile-pic
|
||||
:override-ring? false
|
||||
:uppercase-ratio (:uppercase-ratio
|
||||
constants/initials-avatar-font-conf)
|
||||
:theme (theme/get-theme)})
|
||||
(image-server/get-initials-avatar-uri-fn {:port port
|
||||
:ratio pixel-ratio/ratio
|
||||
:theme (theme/get-theme)
|
||||
:override-ring? false
|
||||
:uppercase-ratio (:uppercase-ratio
|
||||
constants/initials-avatar-font-conf)
|
||||
:font-file font-file}))}))
|
||||
|
||||
(re-frame/reg-sub
|
||||
|
@ -61,11 +68,13 @@
|
|||
{:fn
|
||||
(if image-name
|
||||
(image-server/get-account-image-uri-fn {:port port
|
||||
:ratio pixel-ratio/ratio
|
||||
:image-name image-name
|
||||
:key-uid target-key-uid
|
||||
:theme (theme/get-theme)
|
||||
:override-ring? override-ring?})
|
||||
(image-server/get-initials-avatar-uri-fn {:port port
|
||||
:ratio pixel-ratio/ratio
|
||||
:key-uid target-key-uid
|
||||
:theme (theme/get-theme)
|
||||
:override-ring? override-ring?
|
||||
|
@ -283,7 +292,9 @@
|
|||
avatar-opts (assoc avatar-opts :override-ring? (when ens-name? false))
|
||||
images-with-uri (mapv (fn [{key-uid :keyUid image-name :type :as image}]
|
||||
(let [uri-fn (image-server/get-account-image-uri-fn
|
||||
(merge {:port port
|
||||
(merge
|
||||
{:port port
|
||||
:ratio pixel-ratio/ratio
|
||||
:image-name image-name
|
||||
:key-uid key-uid
|
||||
:theme theme}
|
||||
|
@ -294,6 +305,10 @@
|
|||
images-with-uri
|
||||
[{:fn (image-server/get-initials-avatar-uri-fn
|
||||
(merge {:port port
|
||||
:ratio pixel-ratio/ratio
|
||||
:uppercase-ratio
|
||||
(:uppercase-ratio
|
||||
constants/initials-avatar-font-conf)
|
||||
:key-uid key-uid
|
||||
:theme theme
|
||||
:font-file font-file}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
(:require
|
||||
[react-native.fs :as utils.fs]
|
||||
[react-native.platform :as platform]
|
||||
status-im.common.pixel-ratio
|
||||
[status-im.constants :as constants]
|
||||
[utils.datetime :as datetime]))
|
||||
|
||||
(def ^:const image-server-uri-prefix "https://localhost:")
|
||||
|
@ -19,10 +17,10 @@
|
|||
for ios, it's located at main-bundle-path
|
||||
for android, it's located in the assets dir which can not be accessed by status-go
|
||||
so we copy one to the cache directory"
|
||||
[callback]
|
||||
[font-file-name callback]
|
||||
(if platform/android?
|
||||
(let [cache-dir (utils.fs/cache-dir)
|
||||
font-file-name (:android constants/initials-avatar-font-conf)
|
||||
font-file-name font-file-name
|
||||
src (str "fonts/" font-file-name)
|
||||
dest (str cache-dir "/" font-file-name)
|
||||
copy #(utils.fs/copy-assets src dest)
|
||||
|
@ -34,7 +32,7 @@
|
|||
(.then (copy) cb)))))
|
||||
(callback (str (utils.fs/main-bundle-path)
|
||||
"/"
|
||||
(:ios constants/initials-avatar-font-conf)))))
|
||||
font-file-name))))
|
||||
|
||||
(defn timestamp [] (datetime/timestamp))
|
||||
|
||||
|
@ -70,7 +68,7 @@
|
|||
`indicator-size` - `indicator-border` is inner indicator radius"
|
||||
[{:keys [port public-key image-name key-uid size theme indicator-size
|
||||
indicator-border indicator-center-to-edge indicator-color ring?
|
||||
ring-width]}]
|
||||
ring-width ratio]}]
|
||||
(str
|
||||
image-server-uri-prefix
|
||||
port
|
||||
|
@ -82,7 +80,7 @@
|
|||
"&imageName="
|
||||
image-name
|
||||
"&size="
|
||||
(Math/round (* size status-im.common.pixel-ratio/ratio))
|
||||
(Math/round (* size ratio))
|
||||
"&theme="
|
||||
(current-theme-index theme)
|
||||
"&clock="
|
||||
|
@ -90,15 +88,15 @@
|
|||
"&indicatorColor="
|
||||
(js/encodeURIComponent indicator-color)
|
||||
"&indicatorSize="
|
||||
(* indicator-size status-im.common.pixel-ratio/ratio)
|
||||
(* indicator-size ratio)
|
||||
"&indicatorBorder="
|
||||
(* indicator-border status-im.common.pixel-ratio/ratio)
|
||||
(* indicator-border ratio)
|
||||
"&indicatorCenterToEdge="
|
||||
(* indicator-center-to-edge status-im.common.pixel-ratio/ratio)
|
||||
(* indicator-center-to-edge ratio)
|
||||
"&addRing="
|
||||
(if ring? 1 0)
|
||||
"&ringWidth="
|
||||
(* ring-width status-im.common.pixel-ratio/ratio)))
|
||||
(* ring-width ratio)))
|
||||
|
||||
(defn get-account-image-uri-fn
|
||||
"pass the result fn to user-avatar component as `:profile-picture`
|
||||
|
@ -111,7 +109,7 @@
|
|||
hide ring for account with ens name
|
||||
|
||||
check `get-account-image-uri` for color formats"
|
||||
[{:keys [port public-key key-uid image-name theme override-ring?]}]
|
||||
[{:keys [port public-key key-uid image-name theme override-ring? ratio]}]
|
||||
(fn [{:keys [size indicator-size indicator-border indicator-center-to-edge
|
||||
indicator-color ring? ring-width override-theme]}]
|
||||
(get-account-image-uri
|
||||
|
@ -119,6 +117,7 @@
|
|||
:image-name image-name
|
||||
:size size
|
||||
:public-key public-key
|
||||
:ratio ratio
|
||||
:key-uid key-uid
|
||||
:theme (if (nil? override-theme) theme override-theme)
|
||||
:indicator-size indicator-size
|
||||
|
@ -141,7 +140,7 @@
|
|||
`uppercase-ratio` is the uppercase-height/line-height for `font-file`"
|
||||
[{:keys [port public-key key-uid theme ring? length size background-color color
|
||||
font-size font-file uppercase-ratio indicator-size indicator-border
|
||||
indicator-center-to-edge indicator-color full-name ring-width]}]
|
||||
indicator-center-to-edge indicator-color full-name ring-width ratio]}]
|
||||
(str
|
||||
image-server-uri-prefix
|
||||
port
|
||||
|
@ -153,13 +152,13 @@
|
|||
"&length="
|
||||
length
|
||||
"&size="
|
||||
(Math/round (* size status-im.common.pixel-ratio/ratio))
|
||||
(Math/round (* size ratio))
|
||||
"&bgColor="
|
||||
(js/encodeURIComponent background-color)
|
||||
"&color="
|
||||
(js/encodeURIComponent color)
|
||||
"&fontSize="
|
||||
(* font-size status-im.common.pixel-ratio/ratio)
|
||||
(* font-size ratio)
|
||||
"&fontFile="
|
||||
(js/encodeURIComponent font-file)
|
||||
"&uppercaseRatio="
|
||||
|
@ -173,15 +172,15 @@
|
|||
"&indicatorColor="
|
||||
(js/encodeURIComponent indicator-color)
|
||||
"&indicatorSize="
|
||||
(* indicator-size status-im.common.pixel-ratio/ratio)
|
||||
(* indicator-size ratio)
|
||||
"&indicatorBorder="
|
||||
(* indicator-border status-im.common.pixel-ratio/ratio)
|
||||
(* indicator-border ratio)
|
||||
"&indicatorCenterToEdge="
|
||||
(* indicator-center-to-edge status-im.common.pixel-ratio/ratio)
|
||||
(* indicator-center-to-edge ratio)
|
||||
"&addRing="
|
||||
(if ring? 1 0)
|
||||
"&ringWidth="
|
||||
(* ring-width status-im.common.pixel-ratio/ratio)))
|
||||
(* ring-width ratio)))
|
||||
|
||||
(defn get-initials-avatar-uri-fn
|
||||
"return a fn that calls `get-account-initials-uri`
|
||||
|
@ -191,13 +190,14 @@
|
|||
check `get-font-file-ready` for `font-file`
|
||||
|
||||
check `get-account-image-uri-fn` for `override-ring?`"
|
||||
[{:keys [port public-key key-uid theme override-ring? font-file]}]
|
||||
[{:keys [port public-key key-uid theme override-ring? font-file ratio uppercase-ratio]}]
|
||||
(fn [{:keys [full-name length size background-color font-size color
|
||||
indicator-size indicator-border indicator-color indicator-center-to-edge
|
||||
ring? ring-width override-theme]}]
|
||||
(get-initials-avatar-uri
|
||||
{:port port
|
||||
:public-key public-key
|
||||
:ratio ratio
|
||||
:key-uid key-uid
|
||||
:full-name full-name
|
||||
:length length
|
||||
|
@ -209,7 +209,7 @@
|
|||
:font-size font-size
|
||||
:color color
|
||||
:font-file font-file
|
||||
:uppercase-ratio (:uppercase-ratio constants/initials-avatar-font-conf)
|
||||
:uppercase-ratio uppercase-ratio
|
||||
:indicator-size indicator-size
|
||||
:indicator-border indicator-border
|
||||
:indicator-center-to-edge indicator-center-to-edge
|
||||
|
@ -217,7 +217,7 @@
|
|||
|
||||
(defn get-contact-image-uri
|
||||
[{:keys [port public-key image-name clock theme indicator-size indicator-border
|
||||
indicator-center-to-edge indicator-color size ring? ring-width]}]
|
||||
indicator-center-to-edge indicator-color size ring? ring-width ratio]}]
|
||||
(str
|
||||
image-server-uri-prefix
|
||||
port
|
||||
|
@ -227,7 +227,7 @@
|
|||
"&imageName="
|
||||
image-name
|
||||
"&size="
|
||||
(Math/round (* size status-im.common.pixel-ratio/ratio))
|
||||
(Math/round (* size ratio))
|
||||
"&theme="
|
||||
(current-theme-index theme)
|
||||
"&clock="
|
||||
|
@ -235,21 +235,22 @@
|
|||
"&indicatorColor="
|
||||
(js/encodeURIComponent indicator-color)
|
||||
"&indicatorSize="
|
||||
(* indicator-size status-im.common.pixel-ratio/ratio)
|
||||
(* indicator-size ratio)
|
||||
"&indicatorBorder="
|
||||
(* indicator-border status-im.common.pixel-ratio/ratio)
|
||||
(* indicator-border ratio)
|
||||
"&indicatorCenterToEdge="
|
||||
(* indicator-center-to-edge status-im.common.pixel-ratio/ratio)
|
||||
(* indicator-center-to-edge ratio)
|
||||
"&addRing="
|
||||
(if ring? 1 0)
|
||||
"&ringWidth="
|
||||
(* ring-width status-im.common.pixel-ratio/ratio)))
|
||||
(* ring-width ratio)))
|
||||
|
||||
(defn get-contact-image-uri-fn
|
||||
[{:keys [port public-key image-name theme override-ring? clock]}]
|
||||
[{:keys [port public-key image-name theme override-ring? clock ratio]}]
|
||||
(fn [{:keys [size indicator-size indicator-border indicator-center-to-edge
|
||||
indicator-color ring? ring-width override-theme]}]
|
||||
(get-contact-image-uri {:port port
|
||||
:ratio ratio
|
||||
:image-name image-name
|
||||
:public-key public-key
|
||||
:size size
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
(ns utils.image-server-test
|
||||
(:require
|
||||
[cljs.test :as t]
|
||||
status-im.common.pixel-ratio
|
||||
[utils.image-server :as sut]))
|
||||
|
||||
(t/deftest get-account-image-uri
|
||||
(with-redefs
|
||||
[sut/current-theme-index identity
|
||||
status-im.common.pixel-ratio/ratio 2
|
||||
sut/timestamp (constantly "timestamp")]
|
||||
(t/is
|
||||
(=
|
||||
(sut/get-account-image-uri {:port "port"
|
||||
:public-key "public-key"
|
||||
:ratio 2
|
||||
:image-name "image-name"
|
||||
:key-uid "key-uid"
|
||||
:theme :dark
|
||||
|
@ -26,13 +25,13 @@
|
|||
(t/deftest get-account-initials-uri
|
||||
(with-redefs
|
||||
[sut/current-theme-index identity
|
||||
status-im.common.pixel-ratio/ratio 2
|
||||
sut/timestamp (constantly "timestamp")]
|
||||
(t/is
|
||||
(=
|
||||
(sut/get-initials-avatar-uri
|
||||
{:port "port"
|
||||
:public-key "public-key"
|
||||
:ratio 2
|
||||
:key-uid "key-uid"
|
||||
:full-name "full-name"
|
||||
:length "length"
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
(ns utils.universal-links
|
||||
(:require
|
||||
[goog.string :as gstring]
|
||||
[status-im.constants :as constants]))
|
||||
|
||||
;; domains should be without the trailing slash
|
||||
(def domains
|
||||
{:external "https://status.app"
|
||||
:internal "status-app:/"})
|
||||
|
||||
(def links
|
||||
{:private-chat "%s/p/%s"
|
||||
:user "%s/u#%s"
|
||||
:browse "%s/b/%s"})
|
||||
|
||||
(defn universal-link?
|
||||
[url]
|
||||
(boolean
|
||||
(re-matches constants/regx-universal-link url)))
|
||||
|
||||
(defn deep-link?
|
||||
[url]
|
||||
(boolean
|
||||
(re-matches constants/regx-deep-link url)))
|
||||
|
||||
(defn generate-link
|
||||
[link-type domain-type param]
|
||||
(gstring/format (get links link-type)
|
||||
(get domains domain-type)
|
||||
param))
|
|
@ -1,53 +0,0 @@
|
|||
(ns utils.universal-links-test
|
||||
(:require
|
||||
[cljs.test :refer-macros [deftest testing are]]
|
||||
matcher-combinators.test
|
||||
[utils.universal-links :as links]))
|
||||
|
||||
(deftest universal-link-test
|
||||
(testing "universal-link?"
|
||||
(are [l rst] (match? (links/universal-link? l) rst)
|
||||
"status-app://blah"
|
||||
false
|
||||
"http://status.app/blah"
|
||||
false
|
||||
"http://status.app/c#zQ3shPyZJnxZK4Bwyx9QsaksNKDYTPmpwPvGSjMYVHoXHeEgB"
|
||||
true
|
||||
"http://status.app/u#zQ3shPyZJnxZK4Bwyx9QsaksNKDYTPmpwPvGSjMYVHoXHeEgB"
|
||||
true
|
||||
"https://status.app/u/Ow==#zQ3shsKnV5HJMWJR61c6dssWzHszdbLfBoMF1gcLtSQAYdw2d"
|
||||
true
|
||||
"https://status.app/c/Ow==#zQ3shYSHp7GoiXaauJMnDcjwU2yNjdzpXLosAWapPS4CFxc11"
|
||||
true
|
||||
"https://status.app/c/Ow==#zQ3shYSHp7GoiXaauJMnDcjwU2yNjdzpXLosAWapPS4CFxc111"
|
||||
false
|
||||
"https://status.app/u/G10A4B0JdgwyRww90WXtnP1oNH1ZLQNM0yX0Ja9YyAMjrqSZIYINOHCbFhrnKRAcPGStPxCMJDSZlGCKzmZrJcimHY8BbcXlORrElv_BbQEegnMDPx1g9C5VVNl0fE4y#zQ3shwQPhRuDJSjVGVBnTjCdgXy5i9WQaeVPdGJD6yTarJQSj"
|
||||
true
|
||||
"https://status.app/c/G00AAGS9TbI9mSR-ZNmFrhRjNuEeXAAbcAIUaLLJyjMOG3ACJQ12oIHD78QhzO9s_T5bUeU7rnATWJg3mGgTUemrAg==#zQ3shYf5SquxkiY3FmCW6Nz2wuFWFcM6JEdUD62ApjAvE5YPv"
|
||||
true
|
||||
"http://status.app/c#zQ3shPyZJnxZK4Bwyx9QsaksNKDYTPmpwPvGSjMYVHoXHeEgBhttp://status.app/c#zQ3shPyZJnxZK4Bwyx9QsaksNKDYTPmpwPvGSjMYVHoXHeEgB"
|
||||
false
|
||||
"http://status.app/u#zQ3shPyZJnxZK4Bwyx9QsaksNKDYTPmpwPvGSjMYVHoXHeEgBhttp://status.app/u#zQ3shPyZJnxZK4Bwyx9QsaksNKDYTPmpwPvGSjMYVHoXHeEgB"
|
||||
false
|
||||
"https://status.app/u/Ow==#zQ3shsKnV5HJMWJR61c6dssWzHszdbLfBoMF1gcLtSQAYdw2dhttps://status.app/u/Ow==#zQ3shsKnV5HJMWJR61c6dssWzHszdbLfBoMF1gcLtSQAYdw2d"
|
||||
false
|
||||
"https://status.app/c/Ow==#zQ3shYSHp7GoiXaauJMnDcjwU2yNjdzpXLosAWapPS4CFxc11https://status.app/c/Ow==#zQ3shYSHp7GoiXaauJMnDcjwU2yNjdzpXLosAWapPS4CFxc11"
|
||||
false
|
||||
"https://status.app/u/G10A4B0JdgwyRww90WXtnP1oNH1ZLQNM0yX0Ja9YyAMjrqSZIYINOHCbFhrnKRAcPGStPxCMJDSZlGCKzmZrJcimHY8BbcXlORrElv_BbQEegnMDPx1g9C5VVNl0fE4y#zQ3shwQPhRuDJSjVGVBnTjCdgXy5i9WQaeVPdGJD6yTarJQSjhttps://status.app/u/G10A4B0JdgwyRww90WXtnP1oNH1ZLQNM0yX0Ja9YyAMjrqSZIYINOHCbFhrnKRAcPGStPxCMJDSZlGCKzmZrJcimHY8BbcXlORrElv_BbQEegnMDPx1g9C5VVNl0fE4y#zQ3shwQPhRuDJSjVGVBnTjCdgXy5i9WQaeVPdGJD6yTarJQSj"
|
||||
false
|
||||
"https://status.app/c/Ow==#zQ3shbmfT3hvh4mKa1v6uAjjyztQEroh8Mfn6Ckegjd7LT3XKhttps://status.app/c#zQ3shbmfT3hvh4mKa1v6uAjjyztQEroh8Mfn6Ckegjd7LT3XK"
|
||||
false
|
||||
"https://status.app/blah"
|
||||
false
|
||||
"https://status.app/browse/www.аррӏе.com"
|
||||
false
|
||||
"https://not.status.im/blah"
|
||||
false
|
||||
"http://not.status.im/blah"
|
||||
false))
|
||||
|
||||
(testing "deep-link?"
|
||||
(are [l rst] (match? (links/deep-link? l) rst)
|
||||
"status-app://blah" true
|
||||
"http://status.app/blah" false
|
||||
"ethereum:0x89205a3a3b2a69de6dbf7f01ed13b2108b2c43e7" true)))
|
Loading…
Reference in New Issue