diff --git a/scripts/lint/re-frame-in-quo-components.sh b/scripts/lint/re-frame-in-quo-components.sh index faf6aae8de..645dd47f6e 100755 --- a/scripts/lint/re-frame-in-quo-components.sh +++ b/scripts/lint/re-frame-in-quo-components.sh @@ -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|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|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 diff --git a/src/legacy/status_im/browser/core.cljs b/src/legacy/status_im/browser/core.cljs index 56d5566c7b..1b08969bd3 100644 --- a/src/legacy/status_im/browser/core.cljs +++ b/src/legacy/status_im/browser/core.cljs @@ -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 diff --git a/src/legacy/status_im/wallet/choose_recipient/core.cljs b/src/legacy/status_im/wallet/choose_recipient/core.cljs index d1d2f26366..38e01553f5 100644 --- a/src/legacy/status_im/wallet/choose_recipient/core.cljs +++ b/src/legacy/status_im/wallet/choose_recipient/core.cljs @@ -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 diff --git a/src/status_im/common/font/effects.cljs b/src/status_im/common/font/effects.cljs index 169729bc0f..7b89c2341d 100644 --- a/src/status_im/common/font/effects.cljs +++ b/src/status_im/common/font/effects.cljs @@ -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))) diff --git a/src/status_im/common/router.cljs b/src/status_im/common/router.cljs index 3a26050dca..653910331c 100644 --- a/src/status_im/common/router.cljs +++ b/src/status_im/common/router.cljs @@ -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:") diff --git a/src/status_im/common/universal_links.cljs b/src/status_im/common/universal_links.cljs index 22d8c5cccc..6838b6da0e 100644 --- a/src/status_im/common/universal_links.cljs +++ b/src/status_im/common/universal_links.cljs @@ -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) diff --git a/src/status_im/common/universal_links_test.cljs b/src/status_im/common/universal_links_test.cljs index 2782af0e67..b1ae8fee38 100644 --- a/src/status_im/common/universal_links_test.cljs +++ b/src/status_im/common/universal_links_test.cljs @@ -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))) diff --git a/src/utils/validators.cljs b/src/status_im/common/validators.cljs similarity index 91% rename from src/utils/validators.cljs rename to src/status_im/common/validators.cljs index d6d05b2e02..0c758ac6d7 100644 --- a/src/utils/validators.cljs +++ b/src/status_im/common/validators.cljs @@ -1,4 +1,4 @@ -(ns utils.validators +(ns status-im.common.validators (:require [status-im.constants :as constants])) diff --git a/src/utils/validators_test.cljs b/src/status_im/common/validators_test.cljs similarity index 92% rename from src/utils/validators_test.cljs rename to src/status_im/common/validators_test.cljs index 91868999d4..48c7c90ef8 100644 --- a/src/utils/validators_test.cljs +++ b/src/status_im/common/validators_test.cljs @@ -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" diff --git a/src/status_im/contexts/add_new_contact/events.cljs b/src/status_im/contexts/add_new_contact/events.cljs index 403ffdc0bc..4016dc1ff5 100644 --- a/src/status_im/contexts/add_new_contact/events.cljs +++ b/src/status_im/contexts/add_new_contact/events.cljs @@ -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]). diff --git a/src/status_im/subs/contact.cljs b/src/status_im/subs/contact.cljs index 7100f7f586..ce5e03cb5b 100644 --- a/src/status_im/subs/contact.cljs +++ b/src/status_im/subs/contact.cljs @@ -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] @@ -40,14 +41,20 @@ (let [image-name (:type image) clock (:clock image) uri (image-server/get-contact-image-uri-fn - {:port port - :public-key public-key - :image-name image-name + {:port port + :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)) @@ -56,11 +63,13 @@ images {:thumbnail {:fn (image-server/get-initials-avatar-uri-fn - {:port port - :public-key public-key - :override-ring? (when ens-name false) - :theme theme - :font-file font-file})}})] + {: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})}})] (assoc contact :images images))) diff --git a/src/status_im/subs/profile.cljs b/src/status_im/subs/profile.cljs index 180a2b86d8..41ae06b525 100644 --- a/src/status_im/subs/profile.cljs +++ b/src/status_im/subs/profile.cljs @@ -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] @@ -39,14 +40,20 @@ (fn [[port font-file] [_ profile-pic]] {:fn (if profile-pic - (image-server/get-account-image-uri-fn {:port port - :image-name profile-pic - :override-ring? false - :theme (theme/get-theme)}) - (image-server/get-initials-avatar-uri-fn {:port port - :theme (theme/get-theme) - :override-ring? false - :font-file font-file}))})) + (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 :profile/login-profiles-picture @@ -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,19 +292,25 @@ 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 - :image-name image-name - :key-uid key-uid - :theme theme} - avatar-opts))] + (merge + {:port port + :ratio pixel-ratio/ratio + :image-name image-name + :key-uid key-uid + :theme theme} + avatar-opts))] (assoc image :fn uri-fn))) images) new-images (if (seq images-with-uri) images-with-uri [{:fn (image-server/get-initials-avatar-uri-fn - (merge {:port port - :key-uid key-uid - :theme theme + (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} avatar-opts))}])] (assoc profile :images new-images))) diff --git a/src/utils/image_server.cljs b/src/utils/image_server.cljs index 7ad6b00af1..b34a82baa8 100644 --- a/src/utils/image_server.cljs +++ b/src/utils/image_server.cljs @@ -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 diff --git a/src/utils/image_server_test.cljs b/src/utils/image_server_test.cljs index e1fe77c891..62426f31c1 100644 --- a/src/utils/image_server_test.cljs +++ b/src/utils/image_server_test.cljs @@ -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")] + [sut/current-theme-index identity + 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 @@ -25,14 +24,14 @@ (t/deftest get-account-initials-uri (with-redefs - [sut/current-theme-index identity - status-im.common.pixel-ratio/ratio 2 - sut/timestamp (constantly "timestamp")] + [sut/current-theme-index identity + 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" diff --git a/src/utils/universal_links.cljs b/src/utils/universal_links.cljs deleted file mode 100644 index 77261b66b4..0000000000 --- a/src/utils/universal_links.cljs +++ /dev/null @@ -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)) diff --git a/src/utils/universal_links_test.cljs b/src/utils/universal_links_test.cljs deleted file mode 100644 index 5b082b0976..0000000000 --- a/src/utils/universal_links_test.cljs +++ /dev/null @@ -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)))