diff --git a/src/status_im/contact/db.cljs b/src/status_im/contact/db.cljs index fe2373e53e..ea9b3677ed 100644 --- a/src/status_im/contact/db.cljs +++ b/src/status_im/contact/db.cljs @@ -18,23 +18,12 @@ (spec/def :contact/status (spec/nilable string?)) (spec/def :contact/fcm-token (spec/nilable string?)) (spec/def :contact/description (spec/nilable string?)) - (spec/def :contact/last-updated (spec/nilable int?)) (spec/def :contact/last-online (spec/nilable int?)) (spec/def :contact/pending? boolean?) -(spec/def :contact/unremovable? boolean?) (spec/def :contact/hide-contact? boolean?) - -(spec/def :contact/dapp? boolean?) -(spec/def :contact/dapp-url (spec/nilable string?)) -(spec/def :contact/dapp-hash (spec/nilable int?)) -(spec/def :contact/bot-url (spec/nilable string?)) -(spec/def :contact/command (spec/nilable (spec/map-of int? map?))) -(spec/def :contact/response (spec/nilable (spec/map-of int? map?))) -(spec/def :contact/subscriptions (spec/nilable map?)) -;;true when contact added using status-dev-cli -(spec/def :contact/debug? boolean?) (spec/def :contact/tags (spec/coll-of string? :kind set?)) +(spec/def :contact/blocked? boolean?) (spec/def :contact/contact (spec/keys :req-un [:contact/name] :opt-un [:contact/public-key @@ -45,17 +34,9 @@ :contact/last-online :contact/pending? :contact/hide-contact? - :contact/unremovable? - :contact/dapp? - :contact/dapp-url - :contact/dapp-hash - :contact/bot-url - :contact/command - :contact/response - :contact/debug? - :contact/subscriptions :contact/fcm-token :contact/description + :contact/blocked? :contact/tags])) ;;Contact list ui props diff --git a/src/status_im/contact/subs.cljs b/src/status_im/contact/subs.cljs index 81cd957e14..6bb495096e 100644 --- a/src/status_im/contact/subs.cljs +++ b/src/status_im/contact/subs.cljs @@ -8,15 +8,6 @@ (fn [db] (:contacts/dapps db))) -(re-frame/reg-sub - ::all-added-contacts - :<- [:contacts/contacts] - (fn [contacts] - (->> contacts - (remove (fn [[_ {:keys [pending? hide-contact?]}]] - (or pending? hide-contact?))) - (contact.db/sort-contacts)))) - (re-frame/reg-sub ::query-current-chat-contacts :<- [:chats/current-chat] @@ -29,6 +20,15 @@ (fn [db] (get db :contacts/contacts))) +(re-frame/reg-sub + :contacts/active + :<- [:contacts/contacts] + (fn [contacts] + (->> contacts + (remove (fn [[_ {:keys [pending? hide-contact?]}]] + (or pending? hide-contact?))) + (contact.db/sort-contacts)))) + (re-frame/reg-sub :contacts/current-contact-identity (fn [db] @@ -41,12 +41,6 @@ (fn [[contacts identity]] (contacts identity))) -(re-frame/reg-sub - :contacts/all-added-people-contacts - :<- [::all-added-contacts] - (fn [contacts] - (remove :dapp? contacts))) - (re-frame/reg-sub :contacts/all-dapps :<- [::dapps] diff --git a/src/status_im/data_store/realm/schemas/account/contact.cljs b/src/status_im/data_store/realm/schemas/account/contact.cljs index 50fd5da233..827cb34744 100644 --- a/src/status_im/data_store/realm/schemas/account/contact.cljs +++ b/src/status_im/data_store/realm/schemas/account/contact.cljs @@ -77,3 +77,19 @@ :debug? {:type :bool :default false} :tags {:type "string[]"}}}) + +(def v4 {:name :contact + :primaryKey :public-key + :properties {:address {:type :string :optional true} + :name {:type :string :optional true} + :photo-path {:type :string :optional true} + :last-updated {:type :int :default 0} + :last-online {:type :int :default 0} + :blocked? {:type :bool :default false} + :pending? {:type :bool :default false} + :hide-contact? {:type :bool :default false} + :status {:type :string :optional true} + :fcm-token {:type :string :optional true} + :description {:type :string :optional true} + :public-key :string + :tags {:type "string[]"}}}) diff --git a/src/status_im/data_store/realm/schemas/account/core.cljs b/src/status_im/data_store/realm/schemas/account/core.cljs index 6cb761e197..ba48e26ed2 100644 --- a/src/status_im/data_store/realm/schemas/account/core.cljs +++ b/src/status_im/data_store/realm/schemas/account/core.cljs @@ -399,6 +399,20 @@ dapp-permissions/v9 contact-recovery/v1]) +(def v36 [chat/v14 + transport/v8 + contact/v4 + message/v9 + mailserver/v11 + mailserver-topic/v1 + user-status/v2 + membership-update/v1 + installation/v3 + local-storage/v1 + browser/v8 + dapp-permissions/v9 + contact-recovery/v1]) + ;; put schemas ordered by version (def schemas [{:schema v1 :schemaVersion 1 @@ -504,4 +518,7 @@ :migration migrations/v34} {:schema v35 :schemaVersion 35 - :migration migrations/v35}]) + :migration migrations/v35} + {:schema v36 + :schemaVersion 36 + :migration (constantly nil)}]) diff --git a/src/status_im/ui/screens/add_new/new_chat/views.cljs b/src/status_im/ui/screens/add_new/new_chat/views.cljs index 415ba4c497..83a440724b 100644 --- a/src/status_im/ui/screens/add_new/new_chat/views.cljs +++ b/src/status_im/ui/screens/add_new/new_chat/views.cljs @@ -19,7 +19,7 @@ :show-forward? true}]) (views/defview new-chat [] - (views/letsubs [contacts [:contacts/all-added-people-contacts] + (views/letsubs [contacts [:contacts/active] error-message [:new-identity-error]] [react/keyboard-avoiding-view open-dapp.styles/main-container [status-bar/status-bar] diff --git a/src/status_im/ui/screens/desktop/main/add_new/views.cljs b/src/status_im/ui/screens/desktop/main/add_new/views.cljs index 611905b549..3b8a67804d 100644 --- a/src/status_im/ui/screens/desktop/main/add_new/views.cljs +++ b/src/status_im/ui/screens/desktop/main/add_new/views.cljs @@ -26,7 +26,7 @@ (views/defview new-one-to-one [] (views/letsubs [new-contact-identity [:get :contacts/new-identity] - contacts [:contacts/all-added-people-contacts] + contacts [:contacts/active] chat-error [:new-identity-error]] {:component-will-unmount #(re-frame/dispatch [:new-chat/set-new-identity nil])} [react/view {:style styles/new-view} diff --git a/src/status_im/ui/screens/group/subs.cljs b/src/status_im/ui/screens/group/subs.cljs index bdfab7ad2b..7d233d7c27 100644 --- a/src/status_im/ui/screens/group/subs.cljs +++ b/src/status_im/ui/screens/group/subs.cljs @@ -26,12 +26,12 @@ (fn [selected-participants] (count selected-participants))) -(defn filter-contacts [selected-contacts added-contacts] - (filter #(selected-contacts (:public-key %)) added-contacts)) +(defn filter-contacts [selected-contacts active-contacts] + (filter #(selected-contacts (:public-key %)) active-contacts)) (reg-sub :selected-group-contacts :<- [:get :group/selected-contacts] - :<- [:contacts/all-added-people-contacts] - (fn [[selected-contacts added-contacts]] - (filter-contacts selected-contacts added-contacts))) + :<- [:contacts/active] + (fn [[selected-contacts active-contacts]] + (filter-contacts selected-contacts active-contacts))) diff --git a/src/status_im/ui/screens/group/views.cljs b/src/status_im/ui/screens/group/views.cljs index 6ce9338ae0..a03977a526 100644 --- a/src/status_im/ui/screens/group/views.cljs +++ b/src/status_im/ui/screens/group/views.cljs @@ -121,7 +121,7 @@ ;; Start group chat (views/defview contact-toggle-list [] - (views/letsubs [contacts [:contacts/all-added-people-contacts] + (views/letsubs [contacts [:contacts/active] selected-contacts-count [:selected-contacts-count]] [react/keyboard-avoiding-view {:style styles/group-container} [status-bar/status-bar] diff --git a/src/status_im/ui/screens/wallet/components/views.cljs b/src/status_im/ui/screens/wallet/components/views.cljs index 5febb416f4..3a6384eb23 100644 --- a/src/status_im/ui/screens/wallet/components/views.cljs +++ b/src/status_im/ui/screens/wallet/components/views.cljs @@ -211,7 +211,7 @@ (ethereum/normalized-address (:address contact))]]]]) (views/defview recent-recipients [] - (views/letsubs [contacts [:contacts/all-added-people-contacts]] + (views/letsubs [contacts [:contacts/active]] [simple-screen [toolbar (i18n/label :t/recipient)] [react/view styles/recent-recipients diff --git a/test/cljs/status_im/test/contacts/db.cljs b/test/cljs/status_im/test/contacts/db.cljs index 63256ecdf7..eaa9ae9051 100644 --- a/test/cljs/status_im/test/contacts/db.cljs +++ b/test/cljs/status_im/test/contacts/db.cljs @@ -18,15 +18,11 @@ :address "eca8218b5ebeb2c47ba94c1b6e0a779d78fff7bc", :name "User B", :fcm-token nil, - :dapp-url nil, - :dapp-hash nil, :photo-path "photo1", - :debug? false, :status nil, - :bot-url nil, + :blocked? false, :pending? true, :last-online 0, - :dapp? false, :public-key "0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f"}} current-account {:last-updated 0, @@ -54,13 +50,9 @@ :address "eca8218b5ebeb2c47ba94c1b6e0a779d78fff7bc" :name "User B" :fcm-token nil - :dapp-url nil - :dapp-hash nil :photo-path "photo1" - :debug? false :status nil - :bot-url nil + :blocked? false :pending? true :last-online 0 - :dapp? false :public-key "0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f"}]))))))