fix(profile)_: Fallback to old profile name after migration from v1 (#20412)
This is a byproduct of the investigation on issue https://github.com/status-im/status-mobile/issues/20203, more specifically, to double-check if v1 users have their display names shown correctly. Closes https://github.com/status-im/status-mobile/issues/20203 This is the scenario used to reproduce the bugs this PR is solving: 1. Alice creates an account in v1 (branch release/1.20.x). 2. Alice had 1 friend to chat with, Carol. 3. Alice sends and receives at least one message from Carol. 4. Alice installs the new app (latest develop branch suffices). 5. Alice login and try to edit her profile, but her 3-word name is not displayed in the Settings > Edit Profile screen, nor in the Settings > Edit profile > Name input field. 6. Alice also opens her chat with Carol, but her name appears as a public key instead of her 3-word name she identifies herself with. The solution presented here is to just fallback to Alice's 3-word name (name field in the profile/contact app-db instance). Areas that may be impacted - Edit profile name. - Name displayed in chats from the perspective of the sender who migrated from v1. Steps to test In order to test this PR, it's necessary to migrate from v1 to v2 using two separate builds. The v1 build can be obtained in PR https://github.com/status-im/status-mobile/pull/20123. v2 build can be any one from develop from today, for example.
This commit is contained in:
parent
d2f67ef46c
commit
24b77811d8
|
@ -13,6 +13,7 @@
|
|||
constants/one-day (i18n/label :t/one-day)
|
||||
constants/three-days (i18n/label :t/three-days)
|
||||
constants/one-week (i18n/label :t/one-week)
|
||||
constants/nine-days (i18n/label :t/nine-days)
|
||||
constants/one-month (i18n/label :t/one-month)})
|
||||
|
||||
(defn radio-item
|
||||
|
@ -34,4 +35,5 @@
|
|||
[radio-item constants/one-day default-sync-period]
|
||||
[radio-item constants/three-days default-sync-period]
|
||||
[radio-item constants/one-week default-sync-period]
|
||||
[radio-item constants/nine-days default-sync-period]
|
||||
[radio-item constants/one-month default-sync-period]]))
|
||||
|
|
|
@ -57,14 +57,21 @@
|
|||
:accessory-text (cond
|
||||
(= default-sync-period constants/two-mins)
|
||||
(i18n/label :t/two-minutes)
|
||||
|
||||
(or
|
||||
(nil? default-sync-period)
|
||||
(= default-sync-period constants/one-day))
|
||||
(i18n/label :t/one-day)
|
||||
|
||||
(= default-sync-period constants/three-days)
|
||||
(i18n/label :t/three-days)
|
||||
|
||||
(= default-sync-period constants/nine-days)
|
||||
(i18n/label :t/nine-days)
|
||||
|
||||
(= default-sync-period constants/one-week)
|
||||
(i18n/label :t/one-week)
|
||||
|
||||
(= default-sync-period constants/one-month)
|
||||
(i18n/label :t/one-month))}]
|
||||
[list.item/list-item
|
||||
|
|
|
@ -293,6 +293,7 @@
|
|||
(def ^:const two-mins (* 2 60))
|
||||
(def ^:const one-day (* 60 60 24))
|
||||
(def ^:const three-days (* one-day 3))
|
||||
(def ^:const nine-days (* one-day 9))
|
||||
(def ^:const one-week (* one-day 7))
|
||||
(def ^:const one-month (* one-day 31))
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
name)]
|
||||
(if (or preferred-name (and ens-verified name))
|
||||
ens-name
|
||||
(or display-name primary-name alias))))
|
||||
(or display-name primary-name alias name))))
|
||||
|
||||
(defn photo
|
||||
[{:keys [images]}]
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
(ns status-im.contexts.profile.utils-test
|
||||
(:require
|
||||
[cljs.test :refer [are deftest]]
|
||||
[status-im.contexts.profile.utils :as sut]))
|
||||
|
||||
(deftest displayed-name-test
|
||||
(are [expected arg] (= expected (sut/displayed-name arg))
|
||||
"Display Name" {:display-name "Display Name"}
|
||||
"Primary Name" {:primary-name "Primary Name"}
|
||||
"Alias" {:alias "Alias"}
|
||||
"Name" {:name "Name"}
|
||||
nil {:preferred-name " "}
|
||||
"Preferred Name" {:preferred-name "Preferred Name"}
|
||||
"Preferred Name" {:preferred-name "Preferred Name" :display-name "Display Name"}
|
||||
"Preferred Name" {:preferred-name "Preferred Name" :display-name "Display Name" :name "Name"}
|
||||
"Display Name" {:ens-verified true :name "Name" :display-name "Display Name"}
|
||||
"Name" {:ens-verified true :name "Name" :display-name " "}
|
||||
"Name" {:ens-verified true :name "Name"}
|
||||
"Name" {:name "Name"}))
|
|
@ -258,13 +258,14 @@
|
|||
[(re-frame/subscribe [:contacts/contact-by-identity contact-identity])
|
||||
(re-frame/subscribe [:profile/profile])])
|
||||
(fn [[{:keys [primary-name] :as contact}
|
||||
{:keys [public-key preferred-name display-name]}]
|
||||
{:keys [public-key preferred-name display-name name]}]
|
||||
[_ contact-identity]]
|
||||
[(if (= public-key contact-identity)
|
||||
(cond
|
||||
(not (string/blank? preferred-name)) preferred-name
|
||||
(not (string/blank? display-name)) display-name
|
||||
(not (string/blank? primary-name)) primary-name
|
||||
(not (string/blank? name)) name
|
||||
:else public-key)
|
||||
(profile.utils/displayed-name contact))
|
||||
(:secondary-name contact)]))
|
||||
|
|
|
@ -174,3 +174,37 @@
|
|||
(rf/sub [sub-name]))]
|
||||
(is (= expected-sorted-contacts-without-images
|
||||
(mapv remove-contact-images contact-list-without-identicons))))))
|
||||
|
||||
(h/deftest-sub :contacts/contact-two-names-by-identity
|
||||
[sub-name]
|
||||
(testing "contact is current profile"
|
||||
(let [profile-key "profile-key"]
|
||||
(swap! rf-db/app-db assoc
|
||||
:profile/profile
|
||||
{:public-key profile-key
|
||||
:display-name "Display Name"
|
||||
:name "Name"
|
||||
:preferred-name "Preferred Name"}
|
||||
|
||||
:contacts/contacts
|
||||
{profile-key {:primary-name "Primary Name"}
|
||||
"contact-key" {:secondary-name "Secondary Name"}})
|
||||
|
||||
(is (= ["Preferred Name" nil] (rf/sub [sub-name profile-key])))
|
||||
|
||||
(swap! rf-db/app-db update :profile/profile dissoc :preferred-name)
|
||||
(is (= ["Display Name" nil] (rf/sub [sub-name profile-key])))
|
||||
|
||||
(swap! rf-db/app-db update :profile/profile dissoc :display-name)
|
||||
(is (= ["Primary Name" nil] (rf/sub [sub-name profile-key])))
|
||||
|
||||
(swap! rf-db/app-db update-in [:contacts/contacts profile-key] dissoc :primary-name)
|
||||
(is (= ["Name" nil] (rf/sub [sub-name profile-key])))))
|
||||
|
||||
(testing "contact is not current profile"
|
||||
(swap! rf-db/app-db assoc
|
||||
:profile/profile {:public-key "profile-key"}
|
||||
:contacts/contacts {"contact-key" {:preferred-name "Preferred Name"
|
||||
:secondary-name "Secondary Name"}})
|
||||
|
||||
(is (= ["Preferred Name" "Secondary Name"] (rf/sub [sub-name "contact-key"])))))
|
||||
|
|
|
@ -1863,6 +1863,7 @@
|
|||
"accept-and-add": "Accept and add",
|
||||
"one-day": "One day",
|
||||
"three-days": "Three days",
|
||||
"nine-days": "Nine days",
|
||||
"one-week": "One week",
|
||||
"one-month": "One month",
|
||||
"my-profile": "My profile",
|
||||
|
|
Loading…
Reference in New Issue