diff --git a/src/legacy/status_im/ui/screens/default_sync_period_settings/view.cljs b/src/legacy/status_im/ui/screens/default_sync_period_settings/view.cljs index 02df232fb6..93e56ad0f6 100644 --- a/src/legacy/status_im/ui/screens/default_sync_period_settings/view.cljs +++ b/src/legacy/status_im/ui/screens/default_sync_period_settings/view.cljs @@ -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]])) diff --git a/src/legacy/status_im/ui/screens/sync_settings/views.cljs b/src/legacy/status_im/ui/screens/sync_settings/views.cljs index b1772e6a3b..efe1a6d2d4 100644 --- a/src/legacy/status_im/ui/screens/sync_settings/views.cljs +++ b/src/legacy/status_im/ui/screens/sync_settings/views.cljs @@ -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 diff --git a/src/status_im/constants.cljs b/src/status_im/constants.cljs index ae8854c4c9..be6c66b8a2 100644 --- a/src/status_im/constants.cljs +++ b/src/status_im/constants.cljs @@ -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)) diff --git a/src/status_im/contexts/profile/utils.cljs b/src/status_im/contexts/profile/utils.cljs index f8ca89994d..d687402ef8 100644 --- a/src/status_im/contexts/profile/utils.cljs +++ b/src/status_im/contexts/profile/utils.cljs @@ -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]}] diff --git a/src/status_im/contexts/profile/utils_test.cljs b/src/status_im/contexts/profile/utils_test.cljs new file mode 100644 index 0000000000..b13151a292 --- /dev/null +++ b/src/status_im/contexts/profile/utils_test.cljs @@ -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"})) diff --git a/src/status_im/subs/contact.cljs b/src/status_im/subs/contact.cljs index 20fd37b36d..1a866e1b0f 100644 --- a/src/status_im/subs/contact.cljs +++ b/src/status_im/subs/contact.cljs @@ -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)])) diff --git a/src/status_im/subs/contact_test.cljs b/src/status_im/subs/contact_test.cljs index 55a5fbb3e9..f0111ba253 100644 --- a/src/status_im/subs/contact_test.cljs +++ b/src/status_im/subs/contact_test.cljs @@ -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"]))))) diff --git a/translations/en.json b/translations/en.json index a9b88ba050..910053906d 100644 --- a/translations/en.json +++ b/translations/en.json @@ -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",