Add to Contacts tab does not appear (#636)
This commit is contained in:
parent
285df463e3
commit
d08ca05d33
|
@ -98,8 +98,8 @@
|
||||||
[chat-icon]]]))))
|
[chat-icon]]]))))
|
||||||
|
|
||||||
(defview add-contact-bar []
|
(defview add-contact-bar []
|
||||||
[pending-contact? [:chat :pending-contact?]
|
[chat-id [:get :current-chat-id]
|
||||||
chat-id [:get :current-chat-id]]
|
pending-contact? [:current-contact :pending?]]
|
||||||
(when pending-contact?
|
(when pending-contact?
|
||||||
[touchable-highlight
|
[touchable-highlight
|
||||||
{:on-press #(dispatch [:add-pending-contact chat-id])}
|
{:on-press #(dispatch [:add-pending-contact chat-id])}
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
|
|
||||||
(defview pending-contact-badge
|
(defview pending-contact-badge
|
||||||
[chat-id {:keys [pending-wrapper pending-outer-circle pending-inner-circle]}]
|
[chat-id {:keys [pending-wrapper pending-outer-circle pending-inner-circle]}]
|
||||||
[pending-contact? [:get-in [:chats chat-id :pending-contact?]]]
|
[pending-contact? [:get-in [:contacts chat-id :pending?]]]
|
||||||
(when pending-contact?
|
(when pending-contact?
|
||||||
[view pending-wrapper
|
[view pending-wrapper
|
||||||
[view pending-outer-circle
|
[view pending-outer-circle
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
(anim/set-value offline-opacity 0)
|
(anim/set-value offline-opacity 0)
|
||||||
(when (or (= @network-status :offline) (= @sync-state :offline))
|
(when (or (= @network-status :offline) (= @sync-state :offline))
|
||||||
(start-offline-animation offline-opacity)))
|
(start-offline-animation offline-opacity)))
|
||||||
pending-contact? (subscribe [:chat :pending-contact?])
|
pending-contact? (subscribe [:current-contact :pending?])
|
||||||
view-id (subscribe [:get :view-id])]
|
view-id (subscribe [:get :view-id])]
|
||||||
(r/create-class
|
(r/create-class
|
||||||
{:component-did-mount
|
{:component-did-mount
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[cljs.reader :refer [read-string]]))
|
[cljs.reader :refer [read-string]]))
|
||||||
|
|
||||||
|
|
||||||
(defmethod nav/preload-data! :group-contacts
|
(defmethod nav/preload-data! :group-contacts
|
||||||
[db [_ _ group]]
|
[db [_ _ group]]
|
||||||
(dissoc
|
(dissoc
|
||||||
|
@ -216,12 +215,9 @@
|
||||||
(fn [{:keys [chats contacts]} [_ chat-id]]
|
(fn [{:keys [chats contacts]} [_ chat-id]]
|
||||||
(let [contact (if-let [contact-info (get-in chats [chat-id :contact-info])]
|
(let [contact (if-let [contact-info (get-in chats [chat-id :contact-info])]
|
||||||
(read-string contact-info)
|
(read-string contact-info)
|
||||||
(-> contacts
|
(-> (get contacts chat-id)
|
||||||
(get chat-id)
|
|
||||||
(assoc :pending false)))]
|
(assoc :pending false)))]
|
||||||
(dispatch [::prepare-contact contact])
|
(dispatch [::prepare-contact contact])
|
||||||
(dispatch [:update-chat! {:chat-id chat-id
|
|
||||||
:pending-contact? false}])
|
|
||||||
(dispatch [:watch-contact contact])
|
(dispatch [:watch-contact contact])
|
||||||
(dispatch [:discoveries-send-portions chat-id])))))
|
(dispatch [:discoveries-send-portions chat-id])))))
|
||||||
|
|
||||||
|
@ -279,8 +275,6 @@
|
||||||
(after stop-watching-contact)
|
(after stop-watching-contact)
|
||||||
(u/side-effect!
|
(u/side-effect!
|
||||||
(fn [_ [_ {:keys [whisper-identity] :as contact}]]
|
(fn [_ [_ {:keys [whisper-identity] :as contact}]]
|
||||||
(dispatch [:update-chat! {:chat-id whisper-identity
|
|
||||||
:pending-contact? true}])
|
|
||||||
(dispatch [:update-contact! (assoc contact :pending true)])
|
(dispatch [:update-contact! (assoc contact :pending true)])
|
||||||
(dispatch [:account-update-keys]))))
|
(dispatch [:account-update-keys]))))
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
color-light-gray
|
color-light-gray
|
||||||
color-separator
|
color-separator
|
||||||
color-gray2]]
|
color-gray2]]
|
||||||
[status-im.components.toolbar.styles :refer [toolbar-background2]]))
|
[status-im.components.toolbar.styles :refer [toolbar-background2]]
|
||||||
|
[status-im.utils.platform :as p]))
|
||||||
|
|
||||||
;; Contacts list
|
;; Contacts list
|
||||||
|
|
||||||
|
@ -21,7 +22,8 @@
|
||||||
:background-color toolbar-background2})
|
:background-color toolbar-background2})
|
||||||
|
|
||||||
(def contacts-list-container
|
(def contacts-list-container
|
||||||
{:flex 1})
|
{:flex 1
|
||||||
|
:margin-bottom (when p/ios? 72)})
|
||||||
|
|
||||||
(def empty-contact-groups
|
(def empty-contact-groups
|
||||||
(merge contact-groups
|
(merge contact-groups
|
||||||
|
|
|
@ -3,6 +3,12 @@
|
||||||
(:require [re-frame.core :refer [register-sub subscribe]]
|
(:require [re-frame.core :refer [register-sub subscribe]]
|
||||||
[status-im.utils.identicon :refer [identicon]]))
|
[status-im.utils.identicon :refer [identicon]]))
|
||||||
|
|
||||||
|
(register-sub :current-contact
|
||||||
|
(fn [db [_ k]]
|
||||||
|
(-> @db
|
||||||
|
(get-in [:contacts (:current-chat-id @db) k])
|
||||||
|
(reaction))))
|
||||||
|
|
||||||
(register-sub :get-contacts
|
(register-sub :get-contacts
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(let [contacts (reaction (:contacts @db))]
|
(let [contacts (reaction (:contacts @db))]
|
||||||
|
@ -19,7 +25,7 @@
|
||||||
(register-sub :all-added-contacts
|
(register-sub :all-added-contacts
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(let [contacts (reaction (:contacts @db))]
|
(let [contacts (reaction (:contacts @db))]
|
||||||
(->> (remove #(true? (:pending (second %))) @contacts)
|
(->> (remove #(true? (:pending? (second %))) @contacts)
|
||||||
(sort-contacts)
|
(sort-contacts)
|
||||||
(reaction)))))
|
(reaction)))))
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
(defn contact-can-be-added? [identity]
|
(defn contact-can-be-added? [identity]
|
||||||
(if (contacts/exists? identity)
|
(if (contacts/exists? identity)
|
||||||
(:pending (contacts/get-by-id identity))
|
(:pending? (contacts/get-by-id identity))
|
||||||
true))
|
true))
|
||||||
|
|
||||||
(defn valid-length? [identity]
|
(defn valid-length? [identity]
|
||||||
|
|
|
@ -11,13 +11,13 @@
|
||||||
(data-store/get-by-id-cljs whisper-identity))
|
(data-store/get-by-id-cljs whisper-identity))
|
||||||
|
|
||||||
(defn save
|
(defn save
|
||||||
[{:keys [whisper-identity pending] :as contact}]
|
[{:keys [whisper-identity pending?] :as contact}]
|
||||||
(let [{pending-db :pending
|
(let [{pending-db? :pending?
|
||||||
:as contact-db} (data-store/get-by-id whisper-identity)
|
:as contact-db} (data-store/get-by-id whisper-identity)
|
||||||
contact (assoc contact :pending
|
contact (assoc contact :pending?
|
||||||
(boolean (if contact-db
|
(boolean (if contact-db
|
||||||
(if (nil? pending) pending-db pending)
|
(if (nil? pending?) pending-db? pending?)
|
||||||
pending)))]
|
pending?)))]
|
||||||
(data-store/save contact (if contact-db true false))))
|
(data-store/save contact (if contact-db true false))))
|
||||||
|
|
||||||
(defn save-all
|
(defn save-all
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
(ns status-im.data-store.realm.schemas.account.core
|
(ns status-im.data-store.realm.schemas.account.core
|
||||||
(:require [status-im.data-store.realm.schemas.account.v1.core :as v1]))
|
(:require [status-im.data-store.realm.schemas.account.v1.core :as v1]
|
||||||
|
[status-im.data-store.realm.schemas.account.v2.core :as v2]))
|
||||||
|
|
||||||
; put schemas ordered by version
|
; put schemas ordered by version
|
||||||
(def schemas [{:schema v1/schema
|
(def schemas [{:schema v1/schema
|
||||||
:schemaVersion 1
|
:schemaVersion 1
|
||||||
:migration v1/migration}])
|
:migration v1/migration}
|
||||||
|
{:schema v2/schema
|
||||||
|
:schemaVersion 2
|
||||||
|
:migration v2/migration}])
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
(ns status-im.data-store.realm.schemas.account.v2.chat
|
||||||
|
(:require [taoensso.timbre :as log]
|
||||||
|
[status-im.components.styles :refer [default-chat-color]]))
|
||||||
|
|
||||||
|
(def schema {:name :chat
|
||||||
|
:primaryKey :chat-id
|
||||||
|
:properties {:chat-id :string
|
||||||
|
:name :string
|
||||||
|
:color {:type :string
|
||||||
|
:default default-chat-color}
|
||||||
|
:group-chat {:type :bool
|
||||||
|
:indexed true}
|
||||||
|
:group-admin {:type :string
|
||||||
|
:optional true}
|
||||||
|
:is-active :bool
|
||||||
|
:timestamp :int
|
||||||
|
:contacts {:type :list
|
||||||
|
:objectType :chat-contact}
|
||||||
|
:removed-at {:type :int
|
||||||
|
:optional true}
|
||||||
|
:removed-from-at {:type :int
|
||||||
|
:optional true}
|
||||||
|
:added-to-at {:type :int
|
||||||
|
:optional true}
|
||||||
|
:updated-at {:type :int
|
||||||
|
:optional true}
|
||||||
|
:last-message-id :string
|
||||||
|
:message-overhead {:type :int
|
||||||
|
:default 0}
|
||||||
|
:public-key {:type :string
|
||||||
|
:optional true}
|
||||||
|
:private-key {:type :string
|
||||||
|
:optional true}
|
||||||
|
:contact-info {:type :string
|
||||||
|
:optional true}}})
|
||||||
|
|
||||||
|
(defn migration [old-realm new-realm]
|
||||||
|
(log/debug "migrating chat schema v2"))
|
|
@ -0,0 +1,26 @@
|
||||||
|
(ns status-im.data-store.realm.schemas.account.v2.contact
|
||||||
|
(:require [taoensso.timbre :as log]))
|
||||||
|
|
||||||
|
(def schema {:name :contact
|
||||||
|
:primaryKey :whisper-identity
|
||||||
|
:properties {:address {:type "string" :optional true}
|
||||||
|
:whisper-identity "string"
|
||||||
|
:name {:type "string" :optional true}
|
||||||
|
:photo-path {:type "string" :optional true}
|
||||||
|
:last-updated {:type "int" :default 0}
|
||||||
|
:last-online {:type "int" :default 0}
|
||||||
|
:pending? {:type "bool" :default false}
|
||||||
|
:status {:type "string" :optional true}
|
||||||
|
:public-key {:type :string
|
||||||
|
:optional true}
|
||||||
|
:private-key {:type :string
|
||||||
|
:optional true}
|
||||||
|
:dapp? {:type :bool
|
||||||
|
:default false}
|
||||||
|
:dapp-url {:type :string
|
||||||
|
:optional true}
|
||||||
|
:dapp-hash {:type :int
|
||||||
|
:optional true}}})
|
||||||
|
|
||||||
|
(defn migration [old-realm new-realm]
|
||||||
|
(log/debug "migrating contact schema v2"))
|
|
@ -0,0 +1,32 @@
|
||||||
|
(ns status-im.data-store.realm.schemas.account.v2.core
|
||||||
|
(:require [status-im.data-store.realm.schemas.account.v2.chat :as chat]
|
||||||
|
[status-im.data-store.realm.schemas.account.v1.chat-contact :as chat-contact]
|
||||||
|
[status-im.data-store.realm.schemas.account.v1.command :as command]
|
||||||
|
[status-im.data-store.realm.schemas.account.v2.contact :as contact]
|
||||||
|
[status-im.data-store.realm.schemas.account.v1.discover :as discover]
|
||||||
|
[status-im.data-store.realm.schemas.account.v1.kv-store :as kv-store]
|
||||||
|
[status-im.data-store.realm.schemas.account.v1.message :as message]
|
||||||
|
[status-im.data-store.realm.schemas.account.v1.pending-message :as pending-message]
|
||||||
|
[status-im.data-store.realm.schemas.account.v1.processed-message :as processed-message]
|
||||||
|
[status-im.data-store.realm.schemas.account.v1.request :as request]
|
||||||
|
[status-im.data-store.realm.schemas.account.v1.tag :as tag]
|
||||||
|
[status-im.data-store.realm.schemas.account.v1.user-status :as user-status]
|
||||||
|
[taoensso.timbre :as log]))
|
||||||
|
|
||||||
|
(def schema [chat/schema
|
||||||
|
chat-contact/schema
|
||||||
|
command/schema
|
||||||
|
contact/schema
|
||||||
|
discover/schema
|
||||||
|
kv-store/schema
|
||||||
|
message/schema
|
||||||
|
pending-message/schema
|
||||||
|
processed-message/schema
|
||||||
|
request/schema
|
||||||
|
tag/schema
|
||||||
|
user-status/schema])
|
||||||
|
|
||||||
|
(defn migration [old-realm new-realm]
|
||||||
|
(log/debug "migrating v2 account database: " old-realm new-realm)
|
||||||
|
(chat/migration old-realm new-realm)
|
||||||
|
(contact/migration old-realm new-realm))
|
|
@ -385,24 +385,24 @@
|
||||||
(when from
|
(when from
|
||||||
(let [{{:keys [name profile-image address status]} :contact
|
(let [{{:keys [name profile-image address status]} :contact
|
||||||
{:keys [public private]} :keypair} payload
|
{:keys [public private]} :keypair} payload
|
||||||
|
existing-contact (get contacts from)
|
||||||
contact {:whisper-identity from
|
contact {:whisper-identity from
|
||||||
:public-key public
|
:public-key public
|
||||||
:private-key private
|
:private-key private
|
||||||
:address address
|
:address address
|
||||||
:status status
|
:status status
|
||||||
:photo-path profile-image
|
:photo-path profile-image
|
||||||
:name name}
|
:name name}
|
||||||
contact-exists? (get contacts from)
|
chat {:name name
|
||||||
chat {:name name
|
:chat-id from
|
||||||
:chat-id from
|
:contact-info (prn-str contact)}]
|
||||||
:contact-info (prn-str contact)
|
(if-not existing-contact
|
||||||
:pending-contact? true}]
|
(let [contact (assoc contact :pending? true)]
|
||||||
(if contact-exists?
|
(dispatch [:add-contacts [contact]])
|
||||||
(do
|
(dispatch [:add-chat from chat]))
|
||||||
|
(when-not (:pending? existing-contact)
|
||||||
(dispatch [:update-contact! contact])
|
(dispatch [:update-contact! contact])
|
||||||
(dispatch [:watch-contact contact]))
|
(dispatch [:watch-contact contact]))))))))
|
||||||
(dispatch [:add-chat from chat])))))))
|
|
||||||
|
|
||||||
(register-handler ::post-error
|
(register-handler ::post-error
|
||||||
(u/side-effect!
|
(u/side-effect!
|
||||||
|
|
|
@ -35,6 +35,6 @@
|
||||||
|
|
||||||
(defn identities [contacts]
|
(defn identities [contacts]
|
||||||
(->> (map second contacts)
|
(->> (map second contacts)
|
||||||
(remove (fn [{:keys [dapp? pending]}]
|
(remove (fn [{:keys [dapp? pending?]}]
|
||||||
(or pending dapp?)))
|
(or pending? dapp?)))
|
||||||
(map :whisper-identity)))
|
(map :whisper-identity)))
|
||||||
|
|
Loading…
Reference in New Issue