Skip to content

Commit 711f4b0

Browse files
authored
Merge branch 'develop' into share-community-qr-17993
2 parents d4073bd + a33e7f2 commit 711f4b0

File tree

13 files changed

+178
-7
lines changed

13 files changed

+178
-7
lines changed

src/status_im/common/validation/profile.cljs

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
(ns status-im.common.validation.profile
22
(:require [clojure.string :as string]
3+
[status-im.constants :as constants]
34
[utils.i18n :as i18n]))
45

56
;; NOTE - validation should match with Desktop
67
;; https://github.com/status-im/status-desktop/blob/2ba96803168461088346bf5030df750cb226df4c/ui/imports/utils/Constants.qml#L468
78
(def min-length 5)
8-
(def max-length 24)
99

1010
(def emoji-regex
1111
#"(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])")
@@ -22,7 +22,9 @@
2222

2323
(defn name-too-short? [s] (< (count (string/trim (str s))) min-length))
2424

25-
(defn name-too-long? [s] (> (count (string/trim (str s))) max-length))
25+
(defn name-too-long? [s] (> (count (string/trim (str s))) constants/profile-name-max-length))
26+
27+
(defn bio-too-long? [s] (> (count (string/trim (str s))) constants/profile-bio-max-length))
2628

2729
(defn validation-name
2830
[s]
@@ -39,3 +41,12 @@
3941
{:check (i18n/label :t/special-characters)})
4042
(name-too-short? s) (i18n/label :t/minimum-characters {:min-chars min-length})
4143
(name-too-long? s) (i18n/label :t/profile-name-is-too-long)))
44+
45+
(defn validation-bio
46+
[s]
47+
(cond
48+
(or (= s nil) (= s "")) nil
49+
(has-emojis? s) (i18n/label :t/are-not-allowed {:check (i18n/label :t/emojis)})
50+
(has-special-characters? s) (i18n/label :t/are-not-allowed
51+
{:check (i18n/label :t/special-characters)})
52+
(bio-too-long? s) (i18n/label :t/bio-is-too-long)))

src/status_im/constants.cljs

+1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107

108108
(def ^:const profile-default-color :blue)
109109
(def ^:const profile-name-max-length 24)
110+
(def ^:const profile-bio-max-length 240)
110111
(def ^:const profile-default-currency :usd)
111112

112113
(def ^:const profile-pictures-show-to-contacts-only 1)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(ns status-im.contexts.profile.edit.bio.events
2+
(:require [utils.i18n :as i18n]
3+
[utils.re-frame :as rf]))
4+
5+
(rf/reg-event-fx :profile/edit-profile-bio-success
6+
(fn [_]
7+
{:fx [[:dispatch [:navigate-back]]
8+
[:dispatch
9+
[:toasts/upsert
10+
{:type :positive
11+
:theme :dark
12+
:text (i18n/label :t/bio-added)}]]]}))
13+
14+
(defn edit-profile-bio
15+
[{:keys [db]} [bio]]
16+
{:db (assoc-in db [:profile/profile :bio] bio)
17+
:fx [[:json-rpc/call
18+
[{:method "wakuext_setBio"
19+
:params [bio]
20+
:on-success [:profile/edit-profile-bio-success]}]]]})
21+
22+
(rf/reg-event-fx :profile/edit-bio edit-profile-bio)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
(ns status-im.contexts.profile.edit.bio.events-test
2+
(:require [cljs.test :refer [deftest is]]
3+
matcher-combinators.test
4+
[status-im.contexts.profile.edit.bio.events :as sut]))
5+
6+
(deftest edit-bio-test
7+
(let [new-bio "New Bio text"
8+
cofx {:db {:profile/profile {:bio "Old Bio text"}}}
9+
expected {:db {:profile/profile {:bio new-bio}}
10+
:fx [[:json-rpc/call
11+
[{:method "wakuext_setBio"
12+
:params [new-bio]
13+
:on-success [:profile/edit-profile-bio-success]}]]]}]
14+
(is (match? expected
15+
(sut/edit-profile-bio cofx [new-bio])))))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
(ns status-im.contexts.profile.edit.bio.style)
2+
3+
(defn page-wrapper
4+
[insets]
5+
{:padding-top (:top insets)
6+
:padding-bottom (:bottom insets)
7+
:padding-horizontal 1
8+
:flex 1})
9+
10+
(def screen-container
11+
{:flex 1
12+
:padding-top 14
13+
:padding-horizontal 20
14+
:justify-content :space-between})
15+
16+
(def button-wrapper
17+
{:margin-vertical 12})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
(ns status-im.contexts.profile.edit.bio.view
2+
(:require [clojure.string :as string]
3+
[quo.core :as quo]
4+
[react-native.core :as rn]
5+
[react-native.safe-area :as safe-area]
6+
[reagent.core :as reagent]
7+
[status-im.common.validation.profile :as profile-validator]
8+
[status-im.constants :as constants]
9+
[status-im.contexts.profile.edit.bio.style :as style]
10+
[utils.debounce :as debounce]
11+
[utils.i18n :as i18n]
12+
[utils.re-frame :as rf]))
13+
14+
(defn view
15+
[]
16+
(let [insets (safe-area/get-insets)
17+
profile (rf/sub [:profile/profile-with-image])
18+
customization-color (rf/sub [:profile/customization-color])
19+
profile-bio (:bio profile)
20+
unsaved-bio (reagent/atom profile-bio)
21+
error-msg (reagent/atom nil)
22+
typing? (reagent/atom false)
23+
validate-bio (debounce/debounce (fn [bio]
24+
(reset! error-msg
25+
(profile-validator/validation-bio bio))
26+
(reset! typing? false))
27+
300)
28+
on-change-text (fn [s]
29+
(reset! typing? true)
30+
(reset! unsaved-bio s)
31+
(validate-bio s))]
32+
(fn []
33+
[quo/overlay
34+
{:type :shell
35+
:container-style (style/page-wrapper insets)}
36+
[quo/page-nav
37+
{:key :header
38+
:background :blur
39+
:icon-name :i/arrow-left
40+
:on-press #(rf/dispatch [:navigate-back])}]
41+
[rn/keyboard-avoiding-view
42+
{:key :content
43+
:style style/screen-container}
44+
[rn/view {:style {:gap 22}}
45+
[quo/text-combinations {:title (i18n/label :t/bio)}]
46+
[quo/input
47+
{:theme :dark
48+
:blur? true
49+
:multiline? true
50+
:error? (not (string/blank? @error-msg))
51+
:container-style {:margin-bottom -11}
52+
:default-value @unsaved-bio
53+
:auto-focus true
54+
:char-limit constants/profile-bio-max-length
55+
:label (i18n/label :t/profile-bio)
56+
:placeholder (i18n/label :t/something-about-you)
57+
:on-change-text on-change-text}]
58+
(when-not (string/blank? @error-msg)
59+
[quo/info-message
60+
{:type :error
61+
:size :default
62+
:icon :i/info}
63+
@error-msg])]
64+
[rn/view {:style style/button-wrapper}
65+
[quo/button
66+
{:type :primary
67+
:customization-color customization-color
68+
:on-press (fn []
69+
(rf/dispatch [:profile/edit-bio @unsaved-bio]))
70+
:disabled? (boolean (or @typing? (not (string/blank? @error-msg))))}
71+
(i18n/label :t/save-bio)]]]])))

src/status_im/contexts/profile/edit/list_items.cljs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
(ns status-im.contexts.profile.edit.list-items
2-
(:require [quo.foundations.colors :as colors]
2+
(:require [legacy.status-im.utils.core :as utils]
3+
[quo.foundations.colors :as colors]
34
[status-im.common.not-implemented :as not-implemented]
45
[status-im.contexts.profile.edit.style :as style]
56
[status-im.contexts.profile.utils :as profile.utils]
@@ -10,6 +11,7 @@
1011
[theme]
1112
(let [profile (rf/sub [:profile/profile-with-image])
1213
customization-color (rf/sub [:profile/customization-color])
14+
bio (:bio profile)
1315
full-name (profile.utils/displayed-name profile)]
1416
[{:label (i18n/label :t/profile)
1517
:items [{:title (i18n/label :t/name)
@@ -20,8 +22,10 @@
2022
:action :arrow
2123
:container-style style/item-container}
2224
{:title (i18n/label :t/bio)
23-
:on-press not-implemented/alert
25+
:on-press #(rf/dispatch [:open-modal :edit-bio])
2426
:blur? true
27+
:label :text
28+
:label-props (utils/truncate-str bio 15)
2529
:action :arrow
2630
:container-style style/item-container}
2731
{:title (i18n/label :t/accent-colour)

src/status_im/contexts/profile/events.cljs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
[native-module.core :as native-module]
55
[re-frame.core :as re-frame]
66
[status-im.contexts.profile.edit.accent-colour.events]
7+
[status-im.contexts.profile.edit.bio.events]
78
[status-im.contexts.profile.edit.header.events]
89
[status-im.contexts.profile.edit.name.events]
910
[status-im.contexts.profile.login.events :as profile.login]

src/status_im/contexts/profile/settings/header/view.cljs

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
[:visibility-status-updates/visibility-status-update
2121
public-key])
2222
customization-color (rf/sub [:profile/customization-color])
23+
bio (:bio profile)
2324
full-name (profile.utils/displayed-name profile)
2425
profile-picture (profile.utils/photo profile)
2526
emoji-string (string/join emoji-hash)
@@ -53,6 +54,7 @@
5354
{:title-accessibility-label :username
5455
:container-style style/title-container
5556
:emoji-hash emoji-string
57+
:description bio
5658
:title full-name}]]))
5759

5860
(def view (quo.theme/with-theme f-view))

src/status_im/navigation/screens.cljs

+5
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
[status-im.contexts.preview.quo.main :as quo.preview]
3737
[status-im.contexts.preview.status-im.main :as status-im-preview]
3838
[status-im.contexts.profile.edit.accent-colour.view :as edit-accent-colour]
39+
[status-im.contexts.profile.edit.bio.view :as edit-bio]
3940
[status-im.contexts.profile.edit.name.view :as edit-name]
4041
[status-im.contexts.profile.edit.view :as edit-profile]
4142
[status-im.contexts.profile.profiles.view :as profiles]
@@ -196,6 +197,10 @@
196197
:options options/transparent-modal-screen-options
197198
:component edit-name/view}
198199

200+
{:name :edit-bio
201+
:options options/transparent-modal-screen-options
202+
:component edit-bio/view}
203+
199204
{:name :new-to-status
200205
:options {:theme :dark
201206
:layout options/onboarding-transparent-layout

src/tests/integration_test/profile_test.cljs

+17
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,20 @@
5656
(is (nil? (:image profile))))
5757
(h/logout)
5858
(rf-test/wait-for [::logout/logout-method])))))))
59+
60+
(deftest edit-profile-bio-test
61+
(h/log-headline :edit-profile-bio-test)
62+
(let [new-bio "New bio text"]
63+
(rf-test/run-test-async
64+
(h/with-app-initialized
65+
(h/with-account
66+
(rf/dispatch [:profile/edit-bio new-bio])
67+
(rf-test/wait-for
68+
[:navigate-back]
69+
(rf-test/wait-for
70+
[:toasts/upsert]
71+
(let [profile (rf/sub [:profile/profile])
72+
bio (:bio profile)]
73+
(is (= new-bio bio)))
74+
(h/logout)
75+
(rf-test/wait-for [::logout/logout-method]))))))))

status-go-version.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
44
"owner": "status-im",
55
"repo": "status-go",
6-
"version": "v0.174.6",
7-
"commit-sha1": "f95dd35d131f68645b7c4dc5fbcea955c16e25bd",
8-
"src-sha256": "188chrifz4h3j6fpsrqq83v2vcnpp8y4282k9lhlrkkknfgwz5v2"
6+
"version": "v0.174.8",
7+
"commit-sha1": "8a3e71378f7208f75bd688c02b0ae5c43ca600f2",
8+
"src-sha256": "10wn93xn6xnkg2d8slyygy9rfrwiargm49738bdjj1g4b81220bq"
99
}

translations/en.json

+5
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@
6767
"balance": "Balance",
6868
"begin-set-up": "Begin setup",
6969
"bio": "Bio",
70+
"bio-added": "Bio added",
71+
"bio-is-too-long": "Bio is too long",
7072
"biometric-auth-android-sensor-desc": "Touch sensor",
7173
"biometric-auth-android-sensor-error-desc": "Failed",
7274
"biometric-auth-android-title": "Authentication Required",
@@ -1183,6 +1185,7 @@
11831185
"processing": "Just a moment",
11841186
"product-information": "Product Information",
11851187
"profile": "Profile",
1188+
"profile-bio": "Profile bio",
11861189
"profile-details": "Profile details",
11871190
"profile-name": "Profile name",
11881191
"profile-name-is-too-long": "Profile name is too long",
@@ -1248,6 +1251,7 @@
12481251
"revoke-access": "Revoke access",
12491252
"rpc-url": "RPC URL",
12501253
"save": "Save",
1254+
"save-bio": "Save bio",
12511255
"save-colour": "Save colour",
12521256
"save-name": "Save name",
12531257
"save-password": "Save password",
@@ -1319,6 +1323,7 @@
13191323
"signing": "Signing",
13201324
"signing-a-message": "Signing a message",
13211325
"signing-phrase": "Signing phrase",
1326+
"something-about-you": "Something about you",
13221327
"something-went-wrong": "Something went wrong",
13231328
"soon": "Soon",
13241329
"special-characters": "Special characters",

0 commit comments

Comments
 (0)