diff --git a/src/schema/quo.cljs b/src/schema/quo.cljs index 8e926ca0c20b..ad78a340a174 100644 --- a/src/schema/quo.cljs +++ b/src/schema/quo.cljs @@ -17,7 +17,7 @@ [:ring? :boolean] [:ring-width :int]]) -(def ^:private ?account-image-uri-opts +(def ^:private ?account-image-uri-options [:map [:port :int] [:ratio :double] @@ -26,7 +26,7 @@ [:theme :schema.common/theme] [:override-ring? [:maybe :boolean]]]) -(def ^:private ?initials-image-uri-opts +(def ^:private ?initials-image-uri-options [:map [:port :int] [:ratio :double] @@ -37,7 +37,7 @@ [:public-key {:optional true} [:maybe :string]] [:override-ring? {:optional true} [:maybe :boolean]]]) -(def ^:private ?contact-image-uri-opts +(def ^:private ?contact-image-uri-options [:map [:port :int] [:clock :int] @@ -47,17 +47,17 @@ [:theme :schema.common/theme] [:override-ring? [:maybe :boolean]]]) -(def ?image-uri-config +(def ^:private ?image-uri-config [:or [:map [:kind [:enum :contact]] - [:options ?contact-image-uri-opts]] + [:options ?contact-image-uri-options]] [:map [:kind [:enum :account]] - [:options ?account-image-uri-opts]] + [:options ?account-image-uri-options]] [:map [:kind [:enum :initials]] - [:options ?initials-image-uri-opts]]]) + [:options ?initials-image-uri-options]]]) (def ^:private ?profile-picture-source [:or @@ -69,4 +69,8 @@ [] (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-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)) diff --git a/src/utils/image_server.cljs b/src/utils/image_server.cljs index 720bfc829488..4eac21db6bff 100644 --- a/src/utils/image_server.cljs +++ b/src/utils/image_server.cljs @@ -100,6 +100,14 @@ "&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 @@ -158,14 +166,9 @@ (schema/=> get-initials-avatar-uri [:=> [:cat - [:map - [:color string?] - [:background-color string?] - [:size number?] - [:ratio float?] - [:uppercase-ratio number?] - [:font-size number?] - [:font-file string?]]] + [:union + :schema.quo/initials-image-uri-options + :schema.quo/profile-picture-options]] [:string]]) (defn get-contact-image-uri @@ -204,6 +207,14 @@ "&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)