mirror of
https://github.com/status-im/status-mobile.git
synced 2025-03-01 00:30:49 +00:00
move status-im from utils (#18249)
This commit is contained in:
parent
5ec5838657
commit
ad8d537b9c
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env sh
|
#!/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
|
if test -n "$INVALID_CHANGES"; then
|
||||||
echo "WARNING: re-frame, status-im are not allowed in quo components"
|
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"
|
echo "$INVALID_CHANGES"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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]
|
[native-module.core :as native-module]
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
[react-native.platform :as platform]
|
[react-native.platform :as platform]
|
||||||
|
[status-im.common.universal-links :as links]
|
||||||
[status-im.constants :as constants]
|
[status-im.constants :as constants]
|
||||||
[status-im.contexts.chat.events :as chat.events]
|
[status-im.contexts.chat.events :as chat.events]
|
||||||
[status-im.navigation.events :as navigation]
|
[status-im.navigation.events :as navigation]
|
||||||
@ -27,7 +28,6 @@
|
|||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
[utils.re-frame :as rf]
|
[utils.re-frame :as rf]
|
||||||
[utils.security.core :as security]
|
[utils.security.core :as security]
|
||||||
[utils.universal-links :as links]
|
|
||||||
[utils.url :as url]))
|
[utils.url :as url]))
|
||||||
|
|
||||||
(rf/defn update-browser-option
|
(rf/defn update-browser-option
|
||||||
|
@ -9,12 +9,12 @@
|
|||||||
[legacy.status-im.wallet.utils :as wallet.utils]
|
[legacy.status-im.wallet.utils :as wallet.utils]
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
[status-im.common.router :as router]
|
[status-im.common.router :as router]
|
||||||
|
[status-im.common.universal-links :as links]
|
||||||
[status-im.navigation.events :as navigation]
|
[status-im.navigation.events :as navigation]
|
||||||
[utils.ethereum.chain :as chain]
|
[utils.ethereum.chain :as chain]
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
[utils.money :as money]
|
[utils.money :as money]
|
||||||
[utils.re-frame :as rf]
|
[utils.re-frame :as rf]
|
||||||
[utils.universal-links :as links]
|
|
||||||
[utils.url :as url]))
|
[utils.url :as url]))
|
||||||
|
|
||||||
;; FIXME(Ferossgp): Should be part of QR scanner not wallet
|
;; FIXME(Ferossgp): Should be part of QR scanner not wallet
|
||||||
|
@ -1,8 +1,14 @@
|
|||||||
(ns status-im.common.font.effects
|
(ns status-im.common.font.effects
|
||||||
(:require
|
(:require
|
||||||
|
[react-native.platform :as platform]
|
||||||
|
[status-im.constants :as constants]
|
||||||
utils.image-server
|
utils.image-server
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
(rf/reg-fx :effects.font/get-font-file-for-initials-avatar
|
(rf/reg-fx :effects.font/get-font-file-for-initials-avatar
|
||||||
(fn [callback]
|
(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]
|
[legacy.status-im.ethereum.ens :as ens]
|
||||||
[native-module.core :as native-module]
|
[native-module.core :as native-module]
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
|
[status-im.common.validators :as validators]
|
||||||
[status-im.constants :as constants]
|
[status-im.constants :as constants]
|
||||||
[status-im.contexts.chat.events :as chat.events]
|
[status-im.contexts.chat.events :as chat.events]
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
@ -15,8 +16,7 @@
|
|||||||
[utils.ethereum.eip.eip681 :as eip681]
|
[utils.ethereum.eip.eip681 :as eip681]
|
||||||
[utils.security.core :as security]
|
[utils.security.core :as security]
|
||||||
[utils.transforms :as transforms]
|
[utils.transforms :as transforms]
|
||||||
[utils.url :as url]
|
[utils.url :as url]))
|
||||||
[utils.validators :as validators]))
|
|
||||||
|
|
||||||
(def ethereum-scheme "ethereum:")
|
(def ethereum-scheme "ethereum:")
|
||||||
|
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
(ns status-im.common.universal-links
|
(ns status-im.common.universal-links
|
||||||
(:require
|
(:require
|
||||||
[clojure.string :as string]
|
[clojure.string :as string]
|
||||||
|
[goog.string :as gstring]
|
||||||
[native-module.core :as native-module]
|
[native-module.core :as native-module]
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
[react-native.async-storage :as async-storage]
|
[react-native.async-storage :as async-storage]
|
||||||
[react-native.core :as rn]
|
[react-native.core :as rn]
|
||||||
[schema.core :as schema]
|
[schema.core :as schema]
|
||||||
|
[status-im.constants :as constants]
|
||||||
[status-im.navigation.events :as navigation]
|
[status-im.navigation.events :as navigation]
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[utils.ethereum.chain :as chain]
|
[utils.ethereum.chain :as chain]
|
||||||
@ -17,6 +19,27 @@
|
|||||||
{:external "https://status.app"
|
{:external "https://status.app"
|
||||||
:internal "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
|
(rf/defn handle-browse
|
||||||
[_ {:keys [url]}]
|
[_ {:keys [url]}]
|
||||||
(log/info "universal-links: handling browse" url)
|
(log/info "universal-links: handling browse" url)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
(ns status-im.common.universal-links-test
|
(ns status-im.common.universal-links-test
|
||||||
(:require
|
(:require
|
||||||
[cljs.test :refer-macros [deftest is are testing]]
|
[cljs.test :refer-macros [deftest is are testing]]
|
||||||
|
matcher-combinators.test
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
[status-im.common.universal-links :as links]))
|
[status-im.common.universal-links :as links]))
|
||||||
|
|
||||||
@ -98,3 +99,51 @@
|
|||||||
db {:profile/profile {:public-key pubkey}}
|
db {:profile/profile {:public-key pubkey}}
|
||||||
rst (links/save-profile-url {:db db} ["invalid pubkey"])]
|
rst (links/save-profile-url {:db db} ["invalid pubkey"])]
|
||||||
(is (nil? rst))))))
|
(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
|
(:require
|
||||||
[status-im.constants :as constants]))
|
[status-im.constants :as constants]))
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
(ns utils.validators-test
|
(ns status-im.common.validators-test
|
||||||
(:require
|
(:require
|
||||||
[cljs.test :refer-macros [deftest testing is]]
|
[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
|
(deftest test-valid-compressed-key
|
||||||
(testing "valid"
|
(testing "valid"
|
@ -1,14 +1,14 @@
|
|||||||
(ns status-im.contexts.add-new-contact.events
|
(ns status-im.contexts.add-new-contact.events
|
||||||
(:require
|
(:require
|
||||||
[clojure.string :as string]
|
[clojure.string :as string]
|
||||||
|
[status-im.common.validators :as validators]
|
||||||
status-im.contexts.add-new-contact.effects
|
status-im.contexts.add-new-contact.effects
|
||||||
[status-im.contexts.contacts.events :as data-store.contacts]
|
[status-im.contexts.contacts.events :as data-store.contacts]
|
||||||
[status-im.navigation.events :as navigation]
|
[status-im.navigation.events :as navigation]
|
||||||
[utils.ens.stateofus :as stateofus]
|
[utils.ens.stateofus :as stateofus]
|
||||||
[utils.ethereum.chain :as chain]
|
[utils.ethereum.chain :as chain]
|
||||||
[utils.re-frame :as rf]
|
[utils.re-frame :as rf]
|
||||||
[utils.string :as utils.string]
|
[utils.string :as utils.string]))
|
||||||
[utils.validators :as validators]))
|
|
||||||
|
|
||||||
(defn init-contact
|
(defn init-contact
|
||||||
"Create a new contact (persisted to app-db as [:contacts/new-identity]).
|
"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]
|
[legacy.status-im.ui.screens.profile.visibility-status.utils :as visibility-status-utils]
|
||||||
[quo.theme :as theme]
|
[quo.theme :as theme]
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
|
[status-im.common.pixel-ratio :as pixel-ratio]
|
||||||
[status-im.constants :as constants]
|
[status-im.constants :as constants]
|
||||||
[status-im.contexts.profile.utils :as profile.utils]
|
[status-im.contexts.profile.utils :as profile.utils]
|
||||||
[utils.address :as address]
|
[utils.address :as address]
|
||||||
@ -40,14 +41,20 @@
|
|||||||
(let [image-name (:type image)
|
(let [image-name (:type image)
|
||||||
clock (:clock image)
|
clock (:clock image)
|
||||||
uri (image-server/get-contact-image-uri-fn
|
uri (image-server/get-contact-image-uri-fn
|
||||||
{:port port
|
{:port port
|
||||||
:public-key public-key
|
:ratio pixel-ratio/ratio
|
||||||
:image-name image-name
|
:public-key
|
||||||
|
public-key
|
||||||
|
:image-name
|
||||||
|
image-name
|
||||||
; We pass the clock so that we reload the
|
; We pass the clock so that we reload the
|
||||||
; image if the image is updated
|
; image if the image is updated
|
||||||
:clock clock
|
:clock
|
||||||
:theme theme
|
clock
|
||||||
:override-ring? (when ens-name false)})]
|
:theme
|
||||||
|
theme
|
||||||
|
:override-ring?
|
||||||
|
(when ens-name false)})]
|
||||||
(assoc-in acc [(keyword image-name) :fn] uri)))
|
(assoc-in acc [(keyword image-name) :fn] uri)))
|
||||||
images
|
images
|
||||||
(vals images))
|
(vals images))
|
||||||
@ -56,11 +63,13 @@
|
|||||||
images
|
images
|
||||||
{:thumbnail
|
{:thumbnail
|
||||||
{:fn (image-server/get-initials-avatar-uri-fn
|
{:fn (image-server/get-initials-avatar-uri-fn
|
||||||
{:port port
|
{:port port
|
||||||
:public-key public-key
|
:ratio pixel-ratio/ratio
|
||||||
:override-ring? (when ens-name false)
|
:public-key public-key
|
||||||
:theme theme
|
:override-ring? (when ens-name false)
|
||||||
:font-file font-file})}})]
|
:uppercase-ratio (:uppercase-ratio constants/initials-avatar-font-conf)
|
||||||
|
:theme theme
|
||||||
|
:font-file font-file})}})]
|
||||||
|
|
||||||
(assoc contact :images images)))
|
(assoc contact :images images)))
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
[legacy.status-im.wallet.utils :as wallet.utils]
|
[legacy.status-im.wallet.utils :as wallet.utils]
|
||||||
[quo.theme :as theme]
|
[quo.theme :as theme]
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
|
[status-im.common.pixel-ratio :as pixel-ratio]
|
||||||
[status-im.constants :as constants]
|
[status-im.constants :as constants]
|
||||||
[utils.address :as address]
|
[utils.address :as address]
|
||||||
[utils.image-server :as image-server]
|
[utils.image-server :as image-server]
|
||||||
@ -39,14 +40,20 @@
|
|||||||
(fn [[port font-file] [_ profile-pic]]
|
(fn [[port font-file] [_ profile-pic]]
|
||||||
{:fn
|
{:fn
|
||||||
(if profile-pic
|
(if profile-pic
|
||||||
(image-server/get-account-image-uri-fn {:port port
|
(image-server/get-account-image-uri-fn {:port port
|
||||||
:image-name profile-pic
|
:ratio pixel-ratio/ratio
|
||||||
:override-ring? false
|
:image-name profile-pic
|
||||||
:theme (theme/get-theme)})
|
:override-ring? false
|
||||||
(image-server/get-initials-avatar-uri-fn {:port port
|
:uppercase-ratio (:uppercase-ratio
|
||||||
:theme (theme/get-theme)
|
constants/initials-avatar-font-conf)
|
||||||
:override-ring? false
|
:theme (theme/get-theme)})
|
||||||
:font-file font-file}))}))
|
(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
|
(re-frame/reg-sub
|
||||||
:profile/login-profiles-picture
|
:profile/login-profiles-picture
|
||||||
@ -61,11 +68,13 @@
|
|||||||
{:fn
|
{:fn
|
||||||
(if image-name
|
(if image-name
|
||||||
(image-server/get-account-image-uri-fn {:port port
|
(image-server/get-account-image-uri-fn {:port port
|
||||||
|
:ratio pixel-ratio/ratio
|
||||||
:image-name image-name
|
:image-name image-name
|
||||||
:key-uid target-key-uid
|
:key-uid target-key-uid
|
||||||
:theme (theme/get-theme)
|
:theme (theme/get-theme)
|
||||||
:override-ring? override-ring?})
|
:override-ring? override-ring?})
|
||||||
(image-server/get-initials-avatar-uri-fn {:port port
|
(image-server/get-initials-avatar-uri-fn {:port port
|
||||||
|
:ratio pixel-ratio/ratio
|
||||||
:key-uid target-key-uid
|
:key-uid target-key-uid
|
||||||
:theme (theme/get-theme)
|
:theme (theme/get-theme)
|
||||||
:override-ring? override-ring?
|
:override-ring? override-ring?
|
||||||
@ -283,19 +292,25 @@
|
|||||||
avatar-opts (assoc avatar-opts :override-ring? (when ens-name? false))
|
avatar-opts (assoc avatar-opts :override-ring? (when ens-name? false))
|
||||||
images-with-uri (mapv (fn [{key-uid :keyUid image-name :type :as image}]
|
images-with-uri (mapv (fn [{key-uid :keyUid image-name :type :as image}]
|
||||||
(let [uri-fn (image-server/get-account-image-uri-fn
|
(let [uri-fn (image-server/get-account-image-uri-fn
|
||||||
(merge {:port port
|
(merge
|
||||||
:image-name image-name
|
{:port port
|
||||||
:key-uid key-uid
|
:ratio pixel-ratio/ratio
|
||||||
:theme theme}
|
:image-name image-name
|
||||||
avatar-opts))]
|
:key-uid key-uid
|
||||||
|
:theme theme}
|
||||||
|
avatar-opts))]
|
||||||
(assoc image :fn uri-fn)))
|
(assoc image :fn uri-fn)))
|
||||||
images)
|
images)
|
||||||
new-images (if (seq images-with-uri)
|
new-images (if (seq images-with-uri)
|
||||||
images-with-uri
|
images-with-uri
|
||||||
[{:fn (image-server/get-initials-avatar-uri-fn
|
[{:fn (image-server/get-initials-avatar-uri-fn
|
||||||
(merge {:port port
|
(merge {:port port
|
||||||
:key-uid key-uid
|
:ratio pixel-ratio/ratio
|
||||||
:theme theme
|
:uppercase-ratio
|
||||||
|
(:uppercase-ratio
|
||||||
|
constants/initials-avatar-font-conf)
|
||||||
|
:key-uid key-uid
|
||||||
|
:theme theme
|
||||||
:font-file font-file}
|
:font-file font-file}
|
||||||
avatar-opts))}])]
|
avatar-opts))}])]
|
||||||
(assoc profile :images new-images)))
|
(assoc profile :images new-images)))
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
(:require
|
(:require
|
||||||
[react-native.fs :as utils.fs]
|
[react-native.fs :as utils.fs]
|
||||||
[react-native.platform :as platform]
|
[react-native.platform :as platform]
|
||||||
status-im.common.pixel-ratio
|
|
||||||
[status-im.constants :as constants]
|
|
||||||
[utils.datetime :as datetime]))
|
[utils.datetime :as datetime]))
|
||||||
|
|
||||||
(def ^:const image-server-uri-prefix "https://localhost:")
|
(def ^:const image-server-uri-prefix "https://localhost:")
|
||||||
@ -19,10 +17,10 @@
|
|||||||
for ios, it's located at main-bundle-path
|
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
|
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"
|
so we copy one to the cache directory"
|
||||||
[callback]
|
[font-file-name callback]
|
||||||
(if platform/android?
|
(if platform/android?
|
||||||
(let [cache-dir (utils.fs/cache-dir)
|
(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)
|
src (str "fonts/" font-file-name)
|
||||||
dest (str cache-dir "/" font-file-name)
|
dest (str cache-dir "/" font-file-name)
|
||||||
copy #(utils.fs/copy-assets src dest)
|
copy #(utils.fs/copy-assets src dest)
|
||||||
@ -34,7 +32,7 @@
|
|||||||
(.then (copy) cb)))))
|
(.then (copy) cb)))))
|
||||||
(callback (str (utils.fs/main-bundle-path)
|
(callback (str (utils.fs/main-bundle-path)
|
||||||
"/"
|
"/"
|
||||||
(:ios constants/initials-avatar-font-conf)))))
|
font-file-name))))
|
||||||
|
|
||||||
(defn timestamp [] (datetime/timestamp))
|
(defn timestamp [] (datetime/timestamp))
|
||||||
|
|
||||||
@ -70,7 +68,7 @@
|
|||||||
`indicator-size` - `indicator-border` is inner indicator radius"
|
`indicator-size` - `indicator-border` is inner indicator radius"
|
||||||
[{:keys [port public-key image-name key-uid size theme indicator-size
|
[{:keys [port public-key image-name key-uid size theme indicator-size
|
||||||
indicator-border indicator-center-to-edge indicator-color ring?
|
indicator-border indicator-center-to-edge indicator-color ring?
|
||||||
ring-width]}]
|
ring-width ratio]}]
|
||||||
(str
|
(str
|
||||||
image-server-uri-prefix
|
image-server-uri-prefix
|
||||||
port
|
port
|
||||||
@ -82,7 +80,7 @@
|
|||||||
"&imageName="
|
"&imageName="
|
||||||
image-name
|
image-name
|
||||||
"&size="
|
"&size="
|
||||||
(Math/round (* size status-im.common.pixel-ratio/ratio))
|
(Math/round (* size ratio))
|
||||||
"&theme="
|
"&theme="
|
||||||
(current-theme-index theme)
|
(current-theme-index theme)
|
||||||
"&clock="
|
"&clock="
|
||||||
@ -90,15 +88,15 @@
|
|||||||
"&indicatorColor="
|
"&indicatorColor="
|
||||||
(js/encodeURIComponent indicator-color)
|
(js/encodeURIComponent indicator-color)
|
||||||
"&indicatorSize="
|
"&indicatorSize="
|
||||||
(* indicator-size status-im.common.pixel-ratio/ratio)
|
(* indicator-size ratio)
|
||||||
"&indicatorBorder="
|
"&indicatorBorder="
|
||||||
(* indicator-border status-im.common.pixel-ratio/ratio)
|
(* indicator-border ratio)
|
||||||
"&indicatorCenterToEdge="
|
"&indicatorCenterToEdge="
|
||||||
(* indicator-center-to-edge status-im.common.pixel-ratio/ratio)
|
(* indicator-center-to-edge ratio)
|
||||||
"&addRing="
|
"&addRing="
|
||||||
(if ring? 1 0)
|
(if ring? 1 0)
|
||||||
"&ringWidth="
|
"&ringWidth="
|
||||||
(* ring-width status-im.common.pixel-ratio/ratio)))
|
(* ring-width ratio)))
|
||||||
|
|
||||||
(defn get-account-image-uri-fn
|
(defn get-account-image-uri-fn
|
||||||
"pass the result fn to user-avatar component as `:profile-picture`
|
"pass the result fn to user-avatar component as `:profile-picture`
|
||||||
@ -111,7 +109,7 @@
|
|||||||
hide ring for account with ens name
|
hide ring for account with ens name
|
||||||
|
|
||||||
check `get-account-image-uri` for color formats"
|
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
|
(fn [{:keys [size indicator-size indicator-border indicator-center-to-edge
|
||||||
indicator-color ring? ring-width override-theme]}]
|
indicator-color ring? ring-width override-theme]}]
|
||||||
(get-account-image-uri
|
(get-account-image-uri
|
||||||
@ -119,6 +117,7 @@
|
|||||||
:image-name image-name
|
:image-name image-name
|
||||||
:size size
|
:size size
|
||||||
:public-key public-key
|
:public-key public-key
|
||||||
|
:ratio ratio
|
||||||
:key-uid key-uid
|
:key-uid key-uid
|
||||||
:theme (if (nil? override-theme) theme override-theme)
|
:theme (if (nil? override-theme) theme override-theme)
|
||||||
:indicator-size indicator-size
|
:indicator-size indicator-size
|
||||||
@ -141,7 +140,7 @@
|
|||||||
`uppercase-ratio` is the uppercase-height/line-height for `font-file`"
|
`uppercase-ratio` is the uppercase-height/line-height for `font-file`"
|
||||||
[{:keys [port public-key key-uid theme ring? length size background-color color
|
[{:keys [port public-key key-uid theme ring? length size background-color color
|
||||||
font-size font-file uppercase-ratio indicator-size indicator-border
|
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
|
(str
|
||||||
image-server-uri-prefix
|
image-server-uri-prefix
|
||||||
port
|
port
|
||||||
@ -153,13 +152,13 @@
|
|||||||
"&length="
|
"&length="
|
||||||
length
|
length
|
||||||
"&size="
|
"&size="
|
||||||
(Math/round (* size status-im.common.pixel-ratio/ratio))
|
(Math/round (* size ratio))
|
||||||
"&bgColor="
|
"&bgColor="
|
||||||
(js/encodeURIComponent background-color)
|
(js/encodeURIComponent background-color)
|
||||||
"&color="
|
"&color="
|
||||||
(js/encodeURIComponent color)
|
(js/encodeURIComponent color)
|
||||||
"&fontSize="
|
"&fontSize="
|
||||||
(* font-size status-im.common.pixel-ratio/ratio)
|
(* font-size ratio)
|
||||||
"&fontFile="
|
"&fontFile="
|
||||||
(js/encodeURIComponent font-file)
|
(js/encodeURIComponent font-file)
|
||||||
"&uppercaseRatio="
|
"&uppercaseRatio="
|
||||||
@ -173,15 +172,15 @@
|
|||||||
"&indicatorColor="
|
"&indicatorColor="
|
||||||
(js/encodeURIComponent indicator-color)
|
(js/encodeURIComponent indicator-color)
|
||||||
"&indicatorSize="
|
"&indicatorSize="
|
||||||
(* indicator-size status-im.common.pixel-ratio/ratio)
|
(* indicator-size ratio)
|
||||||
"&indicatorBorder="
|
"&indicatorBorder="
|
||||||
(* indicator-border status-im.common.pixel-ratio/ratio)
|
(* indicator-border ratio)
|
||||||
"&indicatorCenterToEdge="
|
"&indicatorCenterToEdge="
|
||||||
(* indicator-center-to-edge status-im.common.pixel-ratio/ratio)
|
(* indicator-center-to-edge ratio)
|
||||||
"&addRing="
|
"&addRing="
|
||||||
(if ring? 1 0)
|
(if ring? 1 0)
|
||||||
"&ringWidth="
|
"&ringWidth="
|
||||||
(* ring-width status-im.common.pixel-ratio/ratio)))
|
(* ring-width ratio)))
|
||||||
|
|
||||||
(defn get-initials-avatar-uri-fn
|
(defn get-initials-avatar-uri-fn
|
||||||
"return a fn that calls `get-account-initials-uri`
|
"return a fn that calls `get-account-initials-uri`
|
||||||
@ -191,13 +190,14 @@
|
|||||||
check `get-font-file-ready` for `font-file`
|
check `get-font-file-ready` for `font-file`
|
||||||
|
|
||||||
check `get-account-image-uri-fn` for `override-ring?`"
|
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
|
(fn [{:keys [full-name length size background-color font-size color
|
||||||
indicator-size indicator-border indicator-color indicator-center-to-edge
|
indicator-size indicator-border indicator-color indicator-center-to-edge
|
||||||
ring? ring-width override-theme]}]
|
ring? ring-width override-theme]}]
|
||||||
(get-initials-avatar-uri
|
(get-initials-avatar-uri
|
||||||
{:port port
|
{:port port
|
||||||
:public-key public-key
|
:public-key public-key
|
||||||
|
:ratio ratio
|
||||||
:key-uid key-uid
|
:key-uid key-uid
|
||||||
:full-name full-name
|
:full-name full-name
|
||||||
:length length
|
:length length
|
||||||
@ -209,7 +209,7 @@
|
|||||||
:font-size font-size
|
:font-size font-size
|
||||||
:color color
|
:color color
|
||||||
:font-file font-file
|
:font-file font-file
|
||||||
:uppercase-ratio (:uppercase-ratio constants/initials-avatar-font-conf)
|
:uppercase-ratio uppercase-ratio
|
||||||
:indicator-size indicator-size
|
:indicator-size indicator-size
|
||||||
:indicator-border indicator-border
|
:indicator-border indicator-border
|
||||||
:indicator-center-to-edge indicator-center-to-edge
|
:indicator-center-to-edge indicator-center-to-edge
|
||||||
@ -217,7 +217,7 @@
|
|||||||
|
|
||||||
(defn get-contact-image-uri
|
(defn get-contact-image-uri
|
||||||
[{:keys [port public-key image-name clock theme indicator-size indicator-border
|
[{: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
|
(str
|
||||||
image-server-uri-prefix
|
image-server-uri-prefix
|
||||||
port
|
port
|
||||||
@ -227,7 +227,7 @@
|
|||||||
"&imageName="
|
"&imageName="
|
||||||
image-name
|
image-name
|
||||||
"&size="
|
"&size="
|
||||||
(Math/round (* size status-im.common.pixel-ratio/ratio))
|
(Math/round (* size ratio))
|
||||||
"&theme="
|
"&theme="
|
||||||
(current-theme-index theme)
|
(current-theme-index theme)
|
||||||
"&clock="
|
"&clock="
|
||||||
@ -235,21 +235,22 @@
|
|||||||
"&indicatorColor="
|
"&indicatorColor="
|
||||||
(js/encodeURIComponent indicator-color)
|
(js/encodeURIComponent indicator-color)
|
||||||
"&indicatorSize="
|
"&indicatorSize="
|
||||||
(* indicator-size status-im.common.pixel-ratio/ratio)
|
(* indicator-size ratio)
|
||||||
"&indicatorBorder="
|
"&indicatorBorder="
|
||||||
(* indicator-border status-im.common.pixel-ratio/ratio)
|
(* indicator-border ratio)
|
||||||
"&indicatorCenterToEdge="
|
"&indicatorCenterToEdge="
|
||||||
(* indicator-center-to-edge status-im.common.pixel-ratio/ratio)
|
(* indicator-center-to-edge ratio)
|
||||||
"&addRing="
|
"&addRing="
|
||||||
(if ring? 1 0)
|
(if ring? 1 0)
|
||||||
"&ringWidth="
|
"&ringWidth="
|
||||||
(* ring-width status-im.common.pixel-ratio/ratio)))
|
(* ring-width ratio)))
|
||||||
|
|
||||||
(defn get-contact-image-uri-fn
|
(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
|
(fn [{:keys [size indicator-size indicator-border indicator-center-to-edge
|
||||||
indicator-color ring? ring-width override-theme]}]
|
indicator-color ring? ring-width override-theme]}]
|
||||||
(get-contact-image-uri {:port port
|
(get-contact-image-uri {:port port
|
||||||
|
:ratio ratio
|
||||||
:image-name image-name
|
:image-name image-name
|
||||||
:public-key public-key
|
:public-key public-key
|
||||||
:size size
|
:size size
|
||||||
|
@ -1,18 +1,17 @@
|
|||||||
(ns utils.image-server-test
|
(ns utils.image-server-test
|
||||||
(:require
|
(:require
|
||||||
[cljs.test :as t]
|
[cljs.test :as t]
|
||||||
status-im.common.pixel-ratio
|
|
||||||
[utils.image-server :as sut]))
|
[utils.image-server :as sut]))
|
||||||
|
|
||||||
(t/deftest get-account-image-uri
|
(t/deftest get-account-image-uri
|
||||||
(with-redefs
|
(with-redefs
|
||||||
[sut/current-theme-index identity
|
[sut/current-theme-index identity
|
||||||
status-im.common.pixel-ratio/ratio 2
|
sut/timestamp (constantly "timestamp")]
|
||||||
sut/timestamp (constantly "timestamp")]
|
|
||||||
(t/is
|
(t/is
|
||||||
(=
|
(=
|
||||||
(sut/get-account-image-uri {:port "port"
|
(sut/get-account-image-uri {:port "port"
|
||||||
:public-key "public-key"
|
:public-key "public-key"
|
||||||
|
:ratio 2
|
||||||
:image-name "image-name"
|
:image-name "image-name"
|
||||||
:key-uid "key-uid"
|
:key-uid "key-uid"
|
||||||
:theme :dark
|
:theme :dark
|
||||||
@ -25,14 +24,14 @@
|
|||||||
|
|
||||||
(t/deftest get-account-initials-uri
|
(t/deftest get-account-initials-uri
|
||||||
(with-redefs
|
(with-redefs
|
||||||
[sut/current-theme-index identity
|
[sut/current-theme-index identity
|
||||||
status-im.common.pixel-ratio/ratio 2
|
sut/timestamp (constantly "timestamp")]
|
||||||
sut/timestamp (constantly "timestamp")]
|
|
||||||
(t/is
|
(t/is
|
||||||
(=
|
(=
|
||||||
(sut/get-initials-avatar-uri
|
(sut/get-initials-avatar-uri
|
||||||
{:port "port"
|
{:port "port"
|
||||||
:public-key "public-key"
|
:public-key "public-key"
|
||||||
|
:ratio 2
|
||||||
:key-uid "key-uid"
|
:key-uid "key-uid"
|
||||||
:full-name "full-name"
|
:full-name "full-name"
|
||||||
:length "length"
|
: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…
x
Reference in New Issue
Block a user