diff --git a/src/status_im/ui/screens/chat/photos.cljs b/src/status_im/ui/screens/chat/photos.cljs index 11643a4d48..40c7962e22 100644 --- a/src/status_im/ui/screens/chat/photos.cljs +++ b/src/status_im/ui/screens/chat/photos.cljs @@ -2,18 +2,21 @@ (:require [clojure.string :as string] [status-im.ui.components.react :as react] [status-im.ui.screens.chat.styles.photos :as style] + [status-im.ui.screens.profile.db :as profile.db] [status-im.utils.identicon :as identicon] [status-im.utils.image :as utils.image]) (:require-macros [status-im.utils.views :refer [defview letsubs]])) (defn photo [photo-path {:keys [size accessibility-label]}] - [react/view {:style (style/photo-container size)} - [react/image {:source (utils.image/source photo-path) - :style (style/photo size) - :resize-mode :cover - :accessibility-label (or accessibility-label :chat-icon)}] - [react/view {:style (style/photo-border size)}]]) + (let [identicon? (when photo-path (profile.db/base64-png? photo-path))] + [react/view {:style (style/photo-container size)} + [react/image {:source (utils.image/source photo-path) + :style (style/photo size) + :resize-mode :cover + :accessibility-label (or accessibility-label :chat-icon)}] + (when identicon? + [react/view {:style (style/photo-border size)}])])) (defview member-photo [from & [size]] (letsubs [photo-path [:chats/photo-path from]] diff --git a/src/status_im/ui/screens/profile/db.cljs b/src/status_im/ui/screens/profile/db.cljs index bce969a421..f346966a62 100644 --- a/src/status_im/ui/screens/profile/db.cljs +++ b/src/status_im/ui/screens/profile/db.cljs @@ -9,9 +9,15 @@ [(string/blank? username) (string/includes? username chat.constants/command-char)]))) +(defn base64-png? [photo-path] + (string/starts-with? photo-path "data:image/png;base64,")) + +(defn base64-jpeg? [photo-path] + (string/starts-with? photo-path "data:image/jpeg;base64,")) + (defn base64-encoded-image-path? [photo-path] - (or (string/starts-with? photo-path "data:image/jpeg;base64,") - (string/starts-with? photo-path "data:image/png;base64,"))) + (or (base64-png? photo-path) + (base64-jpeg? photo-path))) (spec/def :profile/name correct-name?) (spec/def :profile/status (spec/nilable string?))