From 843de6aa901f745e19350f49310f2d226f8fffdf Mon Sep 17 00:00:00 2001 From: bitsikka Date: Wed, 4 Sep 2019 22:05:15 +0545 Subject: [PATCH] fix profile photo icon - no border in non-identicon photo Signed-off-by: Andrey Shovkoplyas --- src/status_im/ui/screens/chat/photos.cljs | 15 +++++++++------ src/status_im/ui/screens/profile/db.cljs | 10 ++++++++-- 2 files changed, 17 insertions(+), 8 deletions(-) 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?))