diff --git a/src/schema/quo.cljs b/src/schema/quo.cljs index ad78a340a174..a5156c59ec3f 100644 --- a/src/schema/quo.cljs +++ b/src/schema/quo.cljs @@ -48,16 +48,18 @@ [:override-ring? [:maybe :boolean]]]) (def ^:private ?image-uri-config - [:or - [:map - [:kind [:enum :contact]] - [:options ?contact-image-uri-options]] - [:map - [:kind [:enum :account]] - [:options ?account-image-uri-options]] - [:map - [:kind [:enum :initials]] - [:options ?initials-image-uri-options]]]) + [:merge + [:map [:type [:enum :account :contact :initials]]] + [:multi {:dispatch :type} + [:account + [:map + [:options ?account-image-uri-options]]] + [:contact + [:map + [:options ?contact-image-uri-options]]] + [:initials + [:map + [:options ?initials-image-uri-options]]]]]) (def ^:private ?profile-picture-source [:or @@ -67,10 +69,6 @@ (defn register-schemas [] - (registry/register ::profile-picture-options ?profile-picture-options) (registry/register ::image-uri-config ?image-uri-config) (registry/register ::profile-picture-source ?profile-picture-source) - (registry/register ::profile-picture-options ?profile-picture-options) - (registry/register ::account-image-uri-options ?account-image-uri-options) - (registry/register ::contact-image-uri-options ?contact-image-uri-options) - (registry/register ::initials-image-uri-options ?initials-image-uri-options)) + (registry/register ::profile-picture-options ?profile-picture-options)) diff --git a/src/status_im/subs/contact.cljs b/src/status_im/subs/contact.cljs index 7255f597f946..8fd077325f1f 100644 --- a/src/status_im/subs/contact.cljs +++ b/src/status_im/subs/contact.cljs @@ -55,7 +55,7 @@ (when ens-name false)}] (assoc-in acc [(keyword image-name) :config] - {:kind :contact + {:type :contact :options options}))) images (vals images)) @@ -63,7 +63,7 @@ images (if (seq images) images {:thumbnail - {:config {:kind :initials + {:config {:type :initials :options {:port port :ratio pixel-ratio/ratio :public-key public-key diff --git a/src/status_im/subs/profile.cljs b/src/status_im/subs/profile.cljs index d9be2015ca5e..87ed57d6f5b2 100644 --- a/src/status_im/subs/profile.cljs +++ b/src/status_im/subs/profile.cljs @@ -39,7 +39,7 @@ (fn [[port font-file] [_ profile-pic]] {:config (if profile-pic - {:kind :account + {:type :account :options {:port port :ratio pixel-ratio/ratio :image-name profile-pic @@ -47,7 +47,7 @@ :uppercase-ratio (:uppercase-ratio constants/initials-avatar-font-conf) :theme (theme/get-theme)}} - {:kind :initials + {:type :initials :options {:port port :ratio pixel-ratio/ratio :theme (theme/get-theme) @@ -68,14 +68,14 @@ (when profile {:config (if image-name - {:kind :account + {:type :account :options {:port port :ratio pixel-ratio/ratio :image-name image-name :key-uid target-key-uid :theme (theme/get-theme) :override-ring? override-ring?}} - {:kind :initials + {:type :initials :options {:port port :ratio pixel-ratio/ratio :key-uid target-key-uid @@ -328,7 +328,7 @@ images-with-uri (mapv (fn [{key-uid :keyUid image-name :type :as image}] (assoc image :config - {:kind :account + {:type :account :options (merge {:port port :ratio pixel-ratio/ratio @@ -339,7 +339,7 @@ images) new-images (if (seq images-with-uri) images-with-uri - [{:config {:kind :initials + [{:config {:type :initials :options (merge {:port port :ratio pixel-ratio/ratio diff --git a/src/utils/image_server.cljs b/src/utils/image_server.cljs index 4eac21db6bff..93c7028d9afb 100644 --- a/src/utils/image_server.cljs +++ b/src/utils/image_server.cljs @@ -100,14 +100,6 @@ "&ringWidth=" (* ring-width ratio))) -(schema/=> get-account-image-uri - [:=> - [:cat - [:union - :schema.quo/account-image-uri-options - :schema.quo/profile-picture-options]] - [:string]]) - (defn get-initials-avatar-uri "fn to get the avatar uri when account/contact/placeholder has no custom pic set @@ -163,14 +155,6 @@ "&ringWidth=" (* ring-width ratio))) -(schema/=> get-initials-avatar-uri - [:=> - [:cat - [:union - :schema.quo/initials-image-uri-options - :schema.quo/profile-picture-options]] - [:string]]) - (defn get-contact-image-uri "check `get-account-image-uri` for color formats check `get-font-file-ready` for `font-file` @@ -207,14 +191,6 @@ "&ringWidth=" (* ring-width ratio))) -(schema/=> get-contact-image-uri - [:=> - [:cat - [:union - :schema.quo/contact-image-uri-options - :schema.quo/profile-picture-options]] - [:string]]) - (defn get-qr-image-uri-for-any-url [{:keys [url port qr-size error-level]}] (let [qr-url-base64 (js/btoa url) @@ -234,9 +210,9 @@ media-server-url)) (defn get-image-uri - [{:keys [kind options]} + [{:keys [type options]} profile-picture-options] - ((case kind + ((case type :account get-account-image-uri :contact get-contact-image-uri :initials get-initials-avatar-uri