From cdb39452d7942669513383181f916af5e2680a57 Mon Sep 17 00:00:00 2001 From: Mohsen Date: Wed, 24 Apr 2024 20:56:32 +0300 Subject: [PATCH] [#19303] fix: edit profile design feedbacks (#19562) --- src/status_im/common/validation/profile.cljs | 17 +++++++++++------ .../contexts/profile/edit/bio/events.cljs | 4 +++- .../contexts/profile/edit/header/events.cljs | 15 +++++++++------ src/status_im/contexts/profile/edit/style.cljs | 9 ++++----- status-go-version.json | 6 +++--- translations/en.json | 1 + 6 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/status_im/common/validation/profile.cljs b/src/status_im/common/validation/profile.cljs index 44c4e8e626..fff84eaf15 100644 --- a/src/status_im/common/validation/profile.cljs +++ b/src/status_im/common/validation/profile.cljs @@ -9,6 +9,10 @@ ;; https://github.com/status-im/status-desktop/blob/2ba96803168461088346bf5030df750cb226df4c/ui/imports/utils/Constants.qml#L468 (def min-length 5) +;; Combine ASCII and Emoji into one regex +(def bio-chars-regex + #"^[\u00a9\u00ae\u2000-\u3300\ud83c\ud000-\udfff\ud83d\ud000-\udfff\ud83e\ud000-\udfff\u0000-\u007F]+$") + (def common-names ["Ethereum" "Bitcoin"]) (defn has-common-names? [s] (pos? (count (filter #(string/includes? s %) common-names)))) @@ -19,6 +23,10 @@ (defn bio-too-long? [s] (> (count (string/trim (str s))) constants/profile-bio-max-length)) +(defn bio-invalid-characters? + [s] + (not (re-find bio-chars-regex s))) + (defn validation-name [s] (cond @@ -40,12 +48,9 @@ (defn validation-bio [s] (cond - (string/blank? s) nil - (validators/has-emojis? s) (i18n/label :t/are-not-allowed - {:check (i18n/label :t/emojis)}) - (validators/has-special-characters? s) (i18n/label :t/are-not-allowed - {:check (i18n/label :t/special-characters)}) - (bio-too-long? s) (i18n/label :t/bio-is-too-long))) + (string/blank? s) nil + (bio-invalid-characters? s) (i18n/label :t/invalid-characters-bio) + (bio-too-long? s) (i18n/label :t/bio-is-too-long))) (defn validation-nickname [s] diff --git a/src/status_im/contexts/profile/edit/bio/events.cljs b/src/status_im/contexts/profile/edit/bio/events.cljs index c72b8674be..0285cc8cac 100644 --- a/src/status_im/contexts/profile/edit/bio/events.cljs +++ b/src/status_im/contexts/profile/edit/bio/events.cljs @@ -1,5 +1,6 @@ (ns status-im.contexts.profile.edit.bio.events (:require [clojure.string :as string] + [taoensso.timbre :as log] [utils.i18n :as i18n] [utils.re-frame :as rf])) @@ -27,6 +28,7 @@ :params [new-bio] :on-success [:profile/edit-profile-bio-success {:bio new-bio - :added? (string/blank? bio)}]}]]]})) + :added? (string/blank? bio)}] + :on-error #(log/error "failed to set bio " %)}]]]})) (rf/reg-event-fx :profile/edit-bio edit-profile-bio) diff --git a/src/status_im/contexts/profile/edit/header/events.cljs b/src/status_im/contexts/profile/edit/header/events.cljs index b08784bfd1..5e1f787ca3 100644 --- a/src/status_im/contexts/profile/edit/header/events.cljs +++ b/src/status_im/contexts/profile/edit/header/events.cljs @@ -12,12 +12,15 @@ (rf/reg-event-fx :profile/edit-profile-picture-success (fn [_ [images]] - {:fx [[:dispatch [:profile/update-local-picture (reverse images)]] - [:dispatch - [:toasts/upsert - {:type :positive - :theme :dark - :text (i18n/label :t/profile-picture-added)}]]]})) + (let [has-picture? (rf/sub [:profile/has-picture])] + {:fx [[:dispatch [:profile/update-local-picture (reverse images)]] + [:dispatch + [:toasts/upsert + {:type :positive + :theme :dark + :text (i18n/label (if has-picture? + :t/profile-picture-updated + :t/profile-picture-added))}]]]}))) (defn edit-profile-picture [{:keys [db]} [picture crop-width crop-height]] diff --git a/src/status_im/contexts/profile/edit/style.cljs b/src/status_im/contexts/profile/edit/style.cljs index e96cc249dc..5a5edb357c 100644 --- a/src/status_im/contexts/profile/edit/style.cljs +++ b/src/status_im/contexts/profile/edit/style.cljs @@ -15,11 +15,10 @@ :margin-bottom 12}) (def camera-button - {:position :absolute - :border-radius 16 - :overflow :hidden - :right 0 - :bottom 0}) + {:position :absolute + :overflow :hidden + :right 0 + :bottom 0}) (def item-container {:padding-top 14}) diff --git a/status-go-version.json b/status-go-version.json index 3e5d07d4f0..93e2bbf59e 100644 --- a/status-go-version.json +++ b/status-go-version.json @@ -3,7 +3,7 @@ "_comment": "Instead use: scripts/update-status-go.sh ", "owner": "status-im", "repo": "status-go", - "version": "v0.179.7", - "commit-sha1": "cdac86f73ac3bf7f4f4cf09b5bc27fb1602c1820", - "src-sha256": "0svj36zq1v7p1d6dwa29s8m82gfy4ffdcajqcn2wyxxr7i1nwnwa" + "version": "v0.179.8", + "commit-sha1": "70a9996d824e1b5b12560e5b3504c340e416f4dc", + "src-sha256": "1gzzgc5frp5hf7sbzxsakgl648c4h5jn61g0c17fgca46vdk3l9c" } diff --git a/translations/en.json b/translations/en.json index 0234e4f9f8..dcd87b374e 100644 --- a/translations/en.json +++ b/translations/en.json @@ -754,6 +754,7 @@ "invalid-range": "Invalid format, must be between {{min}} and {{max}}", "invalid-username-or-key": "Invalid username or chat key", "invalid-ens-or-key": "Invalid ENS or Chat key", + "invalid-characters-bio": "Invalid characters. Standard keyboard characters and emojis only.", "join-me": "Hey join me on Status: {{url}}", "join-a-community": "or join a community", "join-open-community": "Join Community",