move image-server out of status-im namespace (#15712)

This commit is contained in:
Siddarth Kumar 2023-04-24 14:20:45 +05:30 committed by GitHub
parent 9ddea4805a
commit 8f3fbc22d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 26 deletions

View File

@ -7,11 +7,12 @@
[status-im.group-chats.core :as group-chat] [status-im.group-chats.core :as group-chat]
[status-im.group-chats.db :as group-chats.db] [status-im.group-chats.db :as group-chats.db]
[status-im.multiaccounts.core :as multiaccounts] [status-im.multiaccounts.core :as multiaccounts]
[status-im.utils.image-server :as image-server] [utils.image-server :as image-server]
[status-im2.config :as config] [status-im2.config :as config]
[status-im2.constants :as constants] [status-im2.constants :as constants]
[status-im2.contexts.chat.events :as chat.events] [status-im2.contexts.chat.events :as chat.events]
[utils.i18n :as i18n])) [utils.i18n :as i18n]
[quo2.theme :as theme]))
(re-frame/reg-sub (re-frame/reg-sub
:chats/chat :chats/chat
@ -289,7 +290,7 @@
multiaccount) multiaccount)
(get contacts id))] (get contacts id))]
(if (nil? contact) (if (nil? contact)
(image-server/get-identicons-uri port id) (image-server/get-identicons-uri port id (theme/get-theme))
(multiaccounts/displayed-photo contact))))) (multiaccounts/displayed-photo contact)))))
(re-frame/reg-sub (re-frame/reg-sub

View File

@ -7,9 +7,10 @@
[status-im.multiaccounts.core :as multiaccounts] [status-im.multiaccounts.core :as multiaccounts]
[status-im.ui.screens.profile.visibility-status.utils :as visibility-status-utils] [status-im.ui.screens.profile.visibility-status.utils :as visibility-status-utils]
[status-im.utils.gfycat.core :as gfycat] [status-im.utils.gfycat.core :as gfycat]
[status-im.utils.image-server :as image-server] [utils.image-server :as image-server]
[utils.collection] [utils.collection]
[status-im2.constants :as constants])) [status-im2.constants :as constants]
[quo2.theme :as theme]))
(re-frame/reg-sub (re-frame/reg-sub
::query-current-chat-contacts ::query-current-chat-contacts
@ -32,7 +33,8 @@
(defn- replace-contact-image-uri (defn- replace-contact-image-uri
[contact port identity] [contact port identity]
(let [identicon (image-server/get-identicons-uri port identity) (let [theme (theme/get-theme)
identicon (image-server/get-identicons-uri port identity theme)
contact-images (:images contact) contact-images (:images contact)
contact-images (reduce (fn [acc image] contact-images (reduce (fn [acc image]
(let [image-name (:type image) (let [image-name (:type image)
@ -42,7 +44,8 @@
uri (image-server/get-contact-image-uri port uri (image-server/get-contact-image-uri port
identity identity
image-name image-name
clock)] clock
theme)]
(assoc-in acc [(keyword image-name) :uri] uri))) (assoc-in acc [(keyword image-name) :uri] uri)))
contact-images contact-images
(vals contact-images))] (vals contact-images))]

View File

@ -5,8 +5,9 @@
[status-im.ethereum.core :as ethereum] [status-im.ethereum.core :as ethereum]
[status-im.fleet.core :as fleet] [status-im.fleet.core :as fleet]
[status-im.multiaccounts.db :as multiaccounts.db] [status-im.multiaccounts.db :as multiaccounts.db]
[status-im.utils.image-server :as image-server] [utils.image-server :as image-server]
[utils.security.core :as security])) [utils.security.core :as security]
[quo2.theme :as theme]))
(re-frame/reg-sub (re-frame/reg-sub
:multiaccount/public-key :multiaccount/public-key
@ -208,7 +209,8 @@
(defn- replace-multiaccount-image-uri (defn- replace-multiaccount-image-uri
[multiaccount port] [multiaccount port]
(let [public-key (:public-key multiaccount) (let [public-key (:public-key multiaccount)
identicon (image-server/get-identicons-uri port public-key) theme (theme/get-theme)
identicon (image-server/get-identicons-uri port public-key theme)
multiaccount (assoc multiaccount :identicon identicon) multiaccount (assoc multiaccount :identicon identicon)
images (:images multiaccount) images (:images multiaccount)
images (reduce (fn [acc current] images (reduce (fn [acc current]
@ -217,7 +219,8 @@
uri (image-server/get-account-image-uri port uri (image-server/get-account-image-uri port
public-key public-key
image-name image-name
key-uid)] key-uid
theme)]
(conj acc (assoc current :uri uri)))) (conj acc (assoc current :uri uri))))
[] []
images)] images)]

View File

@ -1,36 +1,34 @@
(ns status-im.utils.image-server (ns utils.image-server
(:require [quo.design-system.colors :as colors])) (:require [utils.datetime :as datetime]))
(def ^:const image-server-uri-prefix "https://localhost:") (def ^:const image-server-uri-prefix "https://localhost:")
(def ^:const identicons-action "/messages/identicons") (def ^:const identicons-action "/messages/identicons")
(def ^:const account-images-action "/accountImages") (def ^:const account-images-action "/accountImages")
(def ^:const contact-images-action "/contactImages") (def ^:const contact-images-action "/contactImages")
(defn current-theme (defn timestamp [] (datetime/timestamp))
[]
(case @colors/theme-type (defn current-theme-index
[theme]
(case theme
:light 1 :light 1
:dark 2)) :dark 2))
(defn- timestamp
[]
(.getTime (js/Date.)))
(defn get-identicons-uri (defn get-identicons-uri
[port public-key] [port public-key theme]
(str image-server-uri-prefix (str image-server-uri-prefix
port port
identicons-action identicons-action
"?publicKey=" "?publicKey="
public-key public-key
"&theme=" "&theme="
(current-theme) (current-theme-index theme)
"&clock=" "&clock="
(timestamp) (timestamp)
"&addRing=1")) "&addRing=1"))
(defn get-account-image-uri (defn get-account-image-uri
[port public-key image-name key-uid] [port public-key image-name key-uid theme]
(str image-server-uri-prefix (str image-server-uri-prefix
port port
account-images-action account-images-action
@ -41,13 +39,13 @@
"&imageName=" "&imageName="
image-name image-name
"&theme=" "&theme="
(current-theme) (current-theme-index theme)
"&clock=" "&clock="
(timestamp) (timestamp)
"&addRing=1")) "&addRing=1"))
(defn get-contact-image-uri (defn get-contact-image-uri
[port public-key image-name clock] [port public-key image-name clock theme]
(str image-server-uri-prefix (str image-server-uri-prefix
port port
contact-images-action contact-images-action
@ -56,7 +54,7 @@
"&imageName=" "&imageName="
image-name image-name
"&theme=" "&theme="
(current-theme) (current-theme-index theme)
"&clock=" "&clock="
clock clock
"&addRing=1")) "&addRing=1"))