removed contacts groups and debug console
Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
parent
7574a1dc25
commit
3f3684cddf
|
@ -237,8 +237,7 @@
|
||||||
(:qr-viewer
|
(:qr-viewer
|
||||||
:recipient-qr-code) "#2f3031"
|
:recipient-qr-code) "#2f3031"
|
||||||
(:accounts :login
|
(:accounts :login
|
||||||
:wallet-transactions-filter
|
:wallet-transactions-filter) styles/color-white
|
||||||
:contact-list-modal) styles/color-white
|
|
||||||
:transparent)})
|
:transparent)})
|
||||||
children (cond-> children
|
children (cond-> children
|
||||||
(#{:wallet
|
(#{:wallet
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
{
|
|
||||||
"dapps":
|
|
||||||
{
|
|
||||||
"name":
|
|
||||||
{
|
|
||||||
"en": "ÐApps"
|
|
||||||
},
|
|
||||||
"contacts":
|
|
||||||
[
|
|
||||||
"oaken-water-meter",
|
|
||||||
"melonport",
|
|
||||||
"bchat",
|
|
||||||
"Dentacoin",
|
|
||||||
"Augur",
|
|
||||||
"Ethlance",
|
|
||||||
"Commiteth",
|
|
||||||
"cryptokitties",
|
|
||||||
"cryptopunks",
|
|
||||||
"name-bazaar",
|
|
||||||
"cent",
|
|
||||||
"erc-dex",
|
|
||||||
"oasis-direct",
|
|
||||||
"etherbots",
|
|
||||||
"peepeth",
|
|
||||||
"hexel",
|
|
||||||
"kyber",
|
|
||||||
"bancor",
|
|
||||||
"opensea",
|
|
||||||
"decentraland",
|
|
||||||
"cryptocribs",
|
|
||||||
"cryptofighters",
|
|
||||||
"airswap"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -175,7 +175,7 @@
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:initialize-chats
|
:initialize-chats
|
||||||
[(re-frame/inject-cofx :get-default-contacts-and-groups)
|
[(re-frame/inject-cofx :get-default-contacts)
|
||||||
(re-frame/inject-cofx :data-store/all-chats)
|
(re-frame/inject-cofx :data-store/all-chats)
|
||||||
(re-frame/inject-cofx :data-store/get-messages)
|
(re-frame/inject-cofx :data-store/get-messages)
|
||||||
(re-frame/inject-cofx :data-store/unviewed-messages)
|
(re-frame/inject-cofx :data-store/unviewed-messages)
|
||||||
|
@ -206,7 +206,6 @@
|
||||||
(handlers-macro/merge-fx cofx
|
(handlers-macro/merge-fx cofx
|
||||||
{:db (assoc db :chats chats)}
|
{:db (assoc db :chats chats)}
|
||||||
(init-console-chat)
|
(init-console-chat)
|
||||||
(group.events/add-default-groups)
|
|
||||||
(add-default-contacts)))))
|
(add-default-contacts)))))
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
|
|
|
@ -2,14 +2,10 @@
|
||||||
(:require [status-im.constants :as constants]
|
(:require [status-im.constants :as constants]
|
||||||
[status-im.i18n :as i18n]
|
[status-im.i18n :as i18n]
|
||||||
[status-im.chat.console :as console-chat]
|
[status-im.chat.console :as console-chat]
|
||||||
[status-im.ui.screens.accounts.utils :as account.utils]
|
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[status-im.i18n :as i18n]
|
[status-im.i18n :as i18n]
|
||||||
[goog.string :as gstring]
|
[goog.string :as gstring]
|
||||||
goog.string.format
|
goog.string.format))
|
||||||
[status-im.utils.handlers-macro :as handlers-macro]))
|
|
||||||
|
|
||||||
;;;; Helper fns
|
|
||||||
|
|
||||||
(defn console-respond-command-messages
|
(defn console-respond-command-messages
|
||||||
[{:keys [name] :as command} handler-data random-id-seq]
|
[{:keys [name] :as command} handler-data random-id-seq]
|
||||||
|
@ -42,7 +38,7 @@
|
||||||
|
|
||||||
(def console-commands->fx
|
(def console-commands->fx
|
||||||
{"faucet"
|
{"faucet"
|
||||||
(fn [{:keys [db random-id] :as cofx} {:keys [params]}]
|
(fn [{:keys [db random-id]} {:keys [params]}]
|
||||||
(let [current-address (get-in db [:account/account :address])
|
(let [current-address (get-in db [:account/account :address])
|
||||||
faucet-url (faucet-base-url->url (:url params))]
|
faucet-url (faucet-base-url->url (:url params))]
|
||||||
{:http-get {:url (gstring/format faucet-url current-address)
|
{:http-get {:url (gstring/format faucet-url current-address)
|
||||||
|
@ -54,24 +50,9 @@
|
||||||
(log/error "Faucet error" event)
|
(log/error "Faucet error" event)
|
||||||
(faucet-response-event
|
(faucet-response-event
|
||||||
random-id
|
random-id
|
||||||
(i18n/label :t/faucet-error)))}}))
|
(i18n/label :t/faucet-error)))}}))})
|
||||||
|
|
||||||
"debug"
|
|
||||||
(fn [{:keys [db random-id now] :as cofx} {:keys [params]}]
|
|
||||||
(let [debug? (= "On" (:mode params))]
|
|
||||||
(handlers-macro/merge-fx cofx
|
|
||||||
{:dispatch-n (if debug?
|
|
||||||
[[:initialize-debugging {:force-start? true}]
|
|
||||||
[:chat-received-message/add
|
|
||||||
[(console-chat/console-message
|
|
||||||
{:message-id random-id
|
|
||||||
:content (i18n/label :t/debug-enabled)
|
|
||||||
:content-type constants/text-content-type})]]]
|
|
||||||
[[:stop-debugging]])}
|
|
||||||
(account.utils/account-update {:debug? debug?
|
|
||||||
:last-updated now}))))})
|
|
||||||
|
|
||||||
(def commands-names (set (keys console-commands->fx)))
|
(def commands-names (set (keys console-commands->fx)))
|
||||||
|
|
||||||
(def commands-with-delivery-status
|
(def commands-with-delivery-status
|
||||||
(disj commands-names "faucet" "debug"))
|
(disj commands-names "faucet"))
|
||||||
|
|
|
@ -1,178 +0,0 @@
|
||||||
(ns status-im.commands.handlers.debug
|
|
||||||
(:require [re-frame.core :as re-frame]
|
|
||||||
[status-im.ui.components.react :as react]
|
|
||||||
[status-im.commands.events.loading :as loading-events]
|
|
||||||
[status-im.data-store.messages :as messages]
|
|
||||||
[status-im.data-store.accounts :as accounts]
|
|
||||||
[status-im.utils.handlers :as handlers]
|
|
||||||
[status-im.utils.platform :as platform]
|
|
||||||
[status-im.utils.types :as types]
|
|
||||||
[taoensso.timbre :as log]))
|
|
||||||
|
|
||||||
(def debug-server-port 5561)
|
|
||||||
|
|
||||||
(defn respond [data]
|
|
||||||
(.respond react/http-bridge
|
|
||||||
200
|
|
||||||
"application/json"
|
|
||||||
(types/clj->json data)))
|
|
||||||
|
|
||||||
(defn debug-server-start []
|
|
||||||
(.start react/http-bridge
|
|
||||||
debug-server-port
|
|
||||||
(if platform/ios?
|
|
||||||
"Status iOS"
|
|
||||||
"Status Android")
|
|
||||||
(fn [req]
|
|
||||||
(try
|
|
||||||
(let [{:keys [postData url]} (js->clj req :keywordize-keys true)
|
|
||||||
postData (if (string? postData)
|
|
||||||
(-> (.parse js/JSON postData)
|
|
||||||
(js->clj :keywordize-keys true))
|
|
||||||
postData)]
|
|
||||||
(re-frame/dispatch [::process-request url postData]))
|
|
||||||
(catch js/Error e
|
|
||||||
(log/debug "Error: " e))))))
|
|
||||||
|
|
||||||
;;;; Specific debug methods
|
|
||||||
;; TODO: there are still a lot of dispatch calls here. we can remove or restructure most of them,
|
|
||||||
;; but to do this we need to also rewrite a lot of already existing functions
|
|
||||||
|
|
||||||
(defn add-contact
|
|
||||||
[{:contacts/keys [contacts]} {:keys [name whisper-identity dapp-url bot-url] :as dapp-data}]
|
|
||||||
(if (and name
|
|
||||||
whisper-identity
|
|
||||||
(or dapp-url bot-url))
|
|
||||||
(if (or (not (get contacts whisper-identity))
|
|
||||||
(get-in contacts [whisper-identity :debug?]))
|
|
||||||
(let [dapp (merge dapp-data {:dapp? true
|
|
||||||
:debug? true})]
|
|
||||||
(re-frame/dispatch [:update-chat! {:chat-id whisper-identity
|
|
||||||
:name name
|
|
||||||
:debug? true}])
|
|
||||||
(if (get contacts whisper-identity)
|
|
||||||
(do (re-frame/dispatch [:update-contact! dapp])
|
|
||||||
(respond {:type :ok
|
|
||||||
:text "The DApp or bot has been updated."}))
|
|
||||||
(do (re-frame/dispatch [:open-chat-with-contact dapp])
|
|
||||||
(respond {:type :ok
|
|
||||||
:text "The DApp or bot has been added."}))))
|
|
||||||
(respond {:type :error
|
|
||||||
:text "Your DApp or bot should be debuggable."}))
|
|
||||||
(respond {:type :error
|
|
||||||
:text (str "You can add either DApp or bot. The object should contain \"name\", "
|
|
||||||
"\"whisper-identity\", and \"dapp-url\" or \"bot-url\" fields.")})))
|
|
||||||
|
|
||||||
(defn remove-contact
|
|
||||||
[{:keys [chats]} {:keys [whisper-identity]}]
|
|
||||||
(if (get chats whisper-identity)
|
|
||||||
(if (get-in chats [whisper-identity :debug?])
|
|
||||||
(do (re-frame/dispatch [:remove-chat-and-navigate-home whisper-identity])
|
|
||||||
(respond {:type :ok
|
|
||||||
:text "The DApp or bot has been removed."}))
|
|
||||||
(respond {:type :error
|
|
||||||
:text "Your DApp or bot should be debuggable."}))
|
|
||||||
(respond {:type :error
|
|
||||||
:text "There is no such DApp or bot."}))
|
|
||||||
(re-frame/dispatch [:remove-contact whisper-identity]))
|
|
||||||
|
|
||||||
(defn contact-changed
|
|
||||||
[{:keys [webview-bridge current-chat-id]
|
|
||||||
:contacts/keys [contacts]} {:keys [whisper-identity] :as dapp-data}]
|
|
||||||
(when (get-in contacts [whisper-identity :debug?])
|
|
||||||
(when (and (= current-chat-id whisper-identity)
|
|
||||||
webview-bridge)
|
|
||||||
(.reload webview-bridge))
|
|
||||||
(when-let [bot-url (get-in contacts [whisper-identity :bot-url])]
|
|
||||||
(re-frame/dispatch [::load-commands! {:whisper-identity whisper-identity
|
|
||||||
:bot-url bot-url}])))
|
|
||||||
(respond {:type :ok
|
|
||||||
:text "Command has been executed."}))
|
|
||||||
|
|
||||||
(defn switch-node
|
|
||||||
[{:keys [account/account]} {:keys [url]}]
|
|
||||||
(re-frame/dispatch [:initialize-protocol (:address account) url])
|
|
||||||
(respond {:type :ok
|
|
||||||
:text "You've successfully switched the node."}))
|
|
||||||
|
|
||||||
(defn dapps-list
|
|
||||||
[{:contacts/keys [contacts]}]
|
|
||||||
(let [contacts (->> (vals contacts)
|
|
||||||
(filter :debug?)
|
|
||||||
(map #(select-keys % [:name :whisper-identity :dapp-url :bot-url])))]
|
|
||||||
(if (seq contacts)
|
|
||||||
(respond {:type :ok
|
|
||||||
:data contacts})
|
|
||||||
(respond {:type :error
|
|
||||||
:text "No DApps or bots found."}))))
|
|
||||||
|
|
||||||
(defn log [db {:keys [identity]}]
|
|
||||||
(let [log (messages/get-log-messages identity)]
|
|
||||||
(if (seq log)
|
|
||||||
(respond {:type :ok
|
|
||||||
:data log})
|
|
||||||
(respond {:type :error
|
|
||||||
:text "No log messages found."}))))
|
|
||||||
|
|
||||||
;;;; FX
|
|
||||||
|
|
||||||
(re-frame/reg-fx
|
|
||||||
::initialize-debugging-fx
|
|
||||||
(fn [[address force-start?]]
|
|
||||||
(if force-start?
|
|
||||||
(debug-server-start)
|
|
||||||
(let [{:keys [debug?]} (accounts/get-by-address address)]
|
|
||||||
(when debug?
|
|
||||||
(debug-server-start))))))
|
|
||||||
|
|
||||||
(re-frame/reg-fx
|
|
||||||
::stop-debugging-fx
|
|
||||||
(fn [_]
|
|
||||||
(.stop react/http-bridge)))
|
|
||||||
|
|
||||||
(re-frame/reg-fx
|
|
||||||
::process-request-fx
|
|
||||||
(fn [[{:keys [web3] :as db} url {:keys [encoded] :as post-data}]]
|
|
||||||
(try
|
|
||||||
(let [json (some->> encoded
|
|
||||||
(.toAscii web3)
|
|
||||||
(.parse js/JSON))
|
|
||||||
obj (when json
|
|
||||||
(js->clj json :keywordize-keys true))]
|
|
||||||
(case url
|
|
||||||
"/add-dapp" (add-contact db obj)
|
|
||||||
"/remove-dapp" (remove-contact db obj)
|
|
||||||
"/dapp-changed" (contact-changed db obj)
|
|
||||||
"/switch-node" (switch-node db obj)
|
|
||||||
"/list" (dapps-list db)
|
|
||||||
"/log" (log db post-data)
|
|
||||||
:default))
|
|
||||||
(catch js/Error e
|
|
||||||
(respond {:type :error :text (str "Error: " e)})
|
|
||||||
(log/debug "Error: " e)))))
|
|
||||||
|
|
||||||
;;;; Handlers
|
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
|
||||||
:initialize-debugging
|
|
||||||
[re-frame/trim-v]
|
|
||||||
(fn [_ [{:keys [address force-start?]}]]
|
|
||||||
{::initialize-debugging-fx [address force-start?]}))
|
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
|
||||||
:stop-debugging
|
|
||||||
(fn [_]
|
|
||||||
{::stop-debugging-fx nil}))
|
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
|
||||||
::process-request
|
|
||||||
[re-frame/trim-v]
|
|
||||||
(fn [{:keys [db]} [url post-data]]
|
|
||||||
{::process-request-fx [db url post-data]}))
|
|
||||||
|
|
||||||
;; TODO(janherich) once `contact-changed` fn is refactored, get rid of this unnecessary event
|
|
||||||
(handlers/register-handler-fx
|
|
||||||
::load-commands
|
|
||||||
[re-frame/trim-v (re-frame/inject-cofx :data-store/get-local-storage-data)]
|
|
||||||
(fn [cofx [contact]]
|
|
||||||
(loading-events/load-commands-for-bot cofx {} contact)))
|
|
|
@ -1,35 +0,0 @@
|
||||||
(ns status-im.data-store.contact-groups
|
|
||||||
(:require [goog.object :as object]
|
|
||||||
[re-frame.core :as re-frame]
|
|
||||||
[status-im.data-store.realm.core :as core]))
|
|
||||||
|
|
||||||
(re-frame/reg-cofx
|
|
||||||
:data-store/get-all-contact-groups
|
|
||||||
(fn [cofx _]
|
|
||||||
(assoc cofx :all-contact-groups (into {}
|
|
||||||
(map (juxt :group-id identity))
|
|
||||||
(-> @core/account-realm
|
|
||||||
(core/get-all :contact-group)
|
|
||||||
(core/all-clj :contact-group))))))
|
|
||||||
|
|
||||||
(defn save-contact-group-tx
|
|
||||||
"Returns tx function for saving contact group"
|
|
||||||
[{:keys [group-id] :as group}]
|
|
||||||
(fn [realm]
|
|
||||||
(core/create realm :contact-group group (core/exists? realm :contact-group :group-id group-id))))
|
|
||||||
|
|
||||||
(defn save-contact-groups-tx
|
|
||||||
"Returns tx function for saving contact groups"
|
|
||||||
[groups]
|
|
||||||
(fn [realm]
|
|
||||||
(doseq [group groups]
|
|
||||||
((save-contact-group-tx group) realm))))
|
|
||||||
|
|
||||||
(defn add-contacts-to-contact-group-tx
|
|
||||||
"Returns tx function for adding contacts to contact group"
|
|
||||||
[group-id contacts]
|
|
||||||
(fn [realm]
|
|
||||||
(let [group (core/single (core/get-by-field realm :contact-group :group-id group-id))
|
|
||||||
existing-contacts (object/get group "contacts")]
|
|
||||||
(aset group "contacts" (clj->js (into #{} (concat contacts
|
|
||||||
(core/list->clj existing-contacts))))))))
|
|
|
@ -9,7 +9,6 @@
|
||||||
status-im.data-store.browser
|
status-im.data-store.browser
|
||||||
status-im.data-store.accounts
|
status-im.data-store.accounts
|
||||||
status-im.data-store.local-storage
|
status-im.data-store.local-storage
|
||||||
status-im.data-store.contact-groups
|
|
||||||
status-im.data-store.requests))
|
status-im.data-store.requests))
|
||||||
|
|
||||||
(defn init [encryption-key]
|
(defn init [encryption-key]
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
(ns status-im.data-store.realm.schemas.account.v1.contact-group
|
|
||||||
(:require [taoensso.timbre :as log]))
|
|
||||||
|
|
||||||
(def schema {:name :contact-group
|
|
||||||
:primaryKey :group-id
|
|
||||||
:properties {:group-id :string
|
|
||||||
:name :string
|
|
||||||
:timestamp :int
|
|
||||||
:order :int
|
|
||||||
:contacts {:type "string[]"}}})
|
|
||||||
|
|
||||||
(defn migration [old-realm new-realm]
|
|
||||||
(log/debug "migrating group schema v1"))
|
|
|
@ -5,13 +5,9 @@
|
||||||
[status-im.data-store.realm.schemas.account.v1.message :as message]
|
[status-im.data-store.realm.schemas.account.v1.message :as message]
|
||||||
[status-im.data-store.realm.schemas.account.v1.request :as request]
|
[status-im.data-store.realm.schemas.account.v1.request :as request]
|
||||||
[status-im.data-store.realm.schemas.account.v1.user-status :as user-status]
|
[status-im.data-store.realm.schemas.account.v1.user-status :as user-status]
|
||||||
[status-im.data-store.realm.schemas.account.v1.contact-group :as contact-group]
|
|
||||||
[status-im.data-store.realm.schemas.account.v1.local-storage :as local-storage]
|
[status-im.data-store.realm.schemas.account.v1.local-storage :as local-storage]
|
||||||
[status-im.data-store.realm.schemas.account.v1.browser :as browser]
|
[status-im.data-store.realm.schemas.account.v1.browser :as browser]
|
||||||
[goog.object :as object]
|
[taoensso.timbre :as log]))
|
||||||
[taoensso.timbre :as log]
|
|
||||||
[cljs.reader :as reader]
|
|
||||||
[clojure.string :as string]))
|
|
||||||
|
|
||||||
(def schema [chat/schema
|
(def schema [chat/schema
|
||||||
transport/schema
|
transport/schema
|
||||||
|
@ -19,7 +15,6 @@
|
||||||
message/schema
|
message/schema
|
||||||
request/schema
|
request/schema
|
||||||
user-status/schema
|
user-status/schema
|
||||||
contact-group/schema
|
|
||||||
local-storage/schema
|
local-storage/schema
|
||||||
browser/schema])
|
browser/schema])
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,7 @@
|
||||||
[status-im.native-module.core :as status]
|
[status-im.native-module.core :as status]
|
||||||
[status-im.utils.config :as config]
|
[status-im.utils.config :as config]
|
||||||
[status-im.utils.keychain :as keychain]
|
[status-im.utils.keychain :as keychain]
|
||||||
[status-im.utils.utils :as utils]
|
[status-im.utils.utils :as utils]))
|
||||||
[status-im.constants :as constants]))
|
|
||||||
|
|
||||||
;;;; FX
|
;;;; FX
|
||||||
|
|
||||||
|
@ -124,9 +123,7 @@
|
||||||
{:db (cond-> (dissoc db :accounts/login)
|
{:db (cond-> (dissoc db :accounts/login)
|
||||||
(= view-id :create-account)
|
(= view-id :create-account)
|
||||||
(assoc-in [:accounts/create :step] :enter-name))
|
(assoc-in [:accounts/create :step] :enter-name))
|
||||||
:dispatch-n (concat
|
:dispatch [:initialize-account address
|
||||||
[[:stop-debugging]
|
|
||||||
[:initialize-account address
|
|
||||||
(when (not= view-id :create-account)
|
(when (not= view-id :create-account)
|
||||||
[[:navigate-to-clean :home]])]])}
|
[[:navigate-to-clean :home]])]}
|
||||||
(log/debug "Error changing acount: " error))))
|
(log/debug "Error changing acount: " error))))
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
:accessibility-label :start-group-chat-button
|
:accessibility-label :start-group-chat-button
|
||||||
:icon :icons/contacts
|
:icon :icons/contacts
|
||||||
:icon-opts {:color colors/blue}
|
:icon-opts {:color colors/blue}
|
||||||
:on-press #(re-frame/dispatch [:open-contact-toggle-list :chat-group])}])
|
:on-press #(re-frame/dispatch [:open-contact-toggle-list])}])
|
||||||
[action-button/action-separator]
|
[action-button/action-separator]
|
||||||
[action-button/action-button
|
[action-button/action-button
|
||||||
{:label (i18n/label :t/new-public-group-chat)
|
{:label (i18n/label :t/new-public-group-chat)
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
(ns status-im.ui.screens.contacts.contact-list.views
|
|
||||||
(:require-macros [status-im.utils.views :refer [defview letsubs]])
|
|
||||||
(:require [re-frame.core :as re-frame]
|
|
||||||
[status-im.ui.components.contact.contact :as contact-view]
|
|
||||||
[status-im.ui.components.list.views :as list]
|
|
||||||
[status-im.ui.components.react :as react]
|
|
||||||
[status-im.ui.components.status-bar.view :as status-bar]
|
|
||||||
[status-im.ui.components.toolbar.view :as toolbar]
|
|
||||||
[status-im.ui.components.toolbar.actions :as act]
|
|
||||||
[status-im.ui.screens.contacts.styles :as styles]
|
|
||||||
[status-im.ui.screens.contacts.views :as contact-options]
|
|
||||||
[status-im.i18n :as i18n]))
|
|
||||||
|
|
||||||
;; TODO(alwx): this namespace is not used; should it be removed?
|
|
||||||
|
|
||||||
(defn render-row [group edit?]
|
|
||||||
(fn [row _ _]
|
|
||||||
[contact-view/contact-view {:contact row
|
|
||||||
:on-press #(re-frame/dispatch [:open-chat-with-contact %])
|
|
||||||
:extended? edit?
|
|
||||||
:extend-options (contact-options/contact-options row group)}]))
|
|
||||||
|
|
||||||
(defview contact-list-toolbar-edit [group]
|
|
||||||
[toolbar/toolbar {}
|
|
||||||
[toolbar/nav-button (act/back #(re-frame/dispatch [:set-in [:contacts/list-ui-props :edit?] false]))]
|
|
||||||
[toolbar/content-title
|
|
||||||
(if-not group
|
|
||||||
(i18n/label :t/contacts)
|
|
||||||
(or (:name group) (i18n/label :t/contacts-group-new-chat)))]])
|
|
||||||
|
|
||||||
(defview contacts-list-view [group edit?]
|
|
||||||
(letsubs [contacts [:get-all-added-group-contacts (:group-id group)]]
|
|
||||||
[list/flat-list {:style styles/contacts-list
|
|
||||||
:data contacts
|
|
||||||
:key-fn :address
|
|
||||||
:render-fn (render-row group edit?)
|
|
||||||
:enableEmptySections true
|
|
||||||
:keyboardShouldPersistTaps :always
|
|
||||||
:header list/default-header
|
|
||||||
:footer list/default-footer}]))
|
|
||||||
|
|
||||||
(defview contact-list []
|
|
||||||
(letsubs [edit? [:get-in [:contacts/list-ui-props :edit?]]
|
|
||||||
group [:get-contact-group]]
|
|
||||||
[react/view {:flex 1}
|
|
||||||
[react/view
|
|
||||||
[status-bar/status-bar]
|
|
||||||
(if edit?
|
|
||||||
[contact-list-toolbar-edit group]
|
|
||||||
[toolbar/simple-toolbar (if-not group
|
|
||||||
(i18n/label :t/contacts)
|
|
||||||
(or (:name group) (i18n/label :t/contacts-group-new-chat)))])]
|
|
||||||
[contacts-list-view group edit?]]))
|
|
|
@ -1,67 +0,0 @@
|
||||||
(ns status-im.ui.screens.contacts.contact-list-modal.views
|
|
||||||
(:require-macros [status-im.utils.views :refer [defview letsubs]])
|
|
||||||
(:require [re-frame.core :refer [dispatch]]
|
|
||||||
[status-im.ui.components.common.common :as common]
|
|
||||||
[status-im.ui.components.contact.contact :refer [contact-view]]
|
|
||||||
[status-im.ui.components.action-button.action-button :refer [action-button
|
|
||||||
action-separator]]
|
|
||||||
[status-im.ui.components.action-button.styles :refer [actions-list]]
|
|
||||||
[status-im.ui.components.list.views :as list]
|
|
||||||
[status-im.ui.components.react :as react]
|
|
||||||
[status-im.ui.components.status-bar.view :refer [status-bar]]
|
|
||||||
[status-im.ui.components.toolbar.view :as toolbar]
|
|
||||||
[status-im.ui.screens.contacts.styles :as st]
|
|
||||||
[status-im.i18n :as i18n]))
|
|
||||||
|
|
||||||
(defn actions-view [action click-handler]
|
|
||||||
[react/view actions-list
|
|
||||||
[action-button
|
|
||||||
{:label (i18n/label :t/enter-address)
|
|
||||||
:icon :icons/address
|
|
||||||
:icon-opts {:color :blue}
|
|
||||||
:on-press #(do
|
|
||||||
(dispatch [:chat-webview-bridge/send-to-bridge
|
|
||||||
{:event (name :webview-send-transaction)}])
|
|
||||||
(dispatch [:navigate-back]))}]
|
|
||||||
[action-separator]
|
|
||||||
(if (= :request action)
|
|
||||||
[action-button {:label (i18n/label :t/show-qr)
|
|
||||||
:icon :icons/qr
|
|
||||||
:icon-opts {:color :blue}
|
|
||||||
:on-press #(click-handler :qr-scan action)}]
|
|
||||||
[action-button {:label (i18n/label :t/scan-qr)
|
|
||||||
:icon :icons/fullscreen
|
|
||||||
:icon-opts {:color :blue}
|
|
||||||
:on-press #(click-handler :qr-scan action)}])])
|
|
||||||
|
|
||||||
(defn render-row [click-handler action params]
|
|
||||||
(fn [row _ _]
|
|
||||||
[contact-view {:contact row
|
|
||||||
:on-press #(when click-handler
|
|
||||||
(click-handler row action params))}]))
|
|
||||||
|
|
||||||
(defview contact-list-modal []
|
|
||||||
(letsubs [contacts [:all-added-people-contacts]
|
|
||||||
click-handler [:get :contacts/click-handler]
|
|
||||||
action [:get :contacts/click-action]
|
|
||||||
params [:get :contacts/click-params]]
|
|
||||||
[react/view {:flex 1 :background-color :white}
|
|
||||||
[status-bar {:type :modal-white}]
|
|
||||||
[toolbar/simple-toolbar (i18n/label :t/contacts)]
|
|
||||||
[list/flat-list {:style st/contacts-list-modal
|
|
||||||
:data contacts
|
|
||||||
:key-fn :address
|
|
||||||
:render-fn (render-row click-handler action params)
|
|
||||||
:header (when-not (:hide-actions? params)
|
|
||||||
[react/view
|
|
||||||
[actions-view action click-handler]
|
|
||||||
[common/bottom-shadow]
|
|
||||||
[common/form-title (i18n/label :t/choose-from-contacts)
|
|
||||||
{:count-value (count contacts)}]
|
|
||||||
[common/list-header]])
|
|
||||||
:footer [react/view
|
|
||||||
[common/list-footer]
|
|
||||||
[common/bottom-shadow]]
|
|
||||||
:enableEmptySections true
|
|
||||||
:bounces false
|
|
||||||
:keyboardShouldPersistTaps :always}]]))
|
|
|
@ -1,9 +1,6 @@
|
||||||
(ns status-im.ui.screens.contacts.core
|
(ns status-im.ui.screens.contacts.core
|
||||||
(:require [re-frame.core :as re-frame]
|
(:require [status-im.utils.handlers-macro :as handlers-macro]
|
||||||
[status-im.utils.handlers-macro :as handlers-macro]
|
|
||||||
[status-im.data-store.messages :as data-store.messages]
|
|
||||||
[status-im.chat.models :as chat.models]
|
[status-im.chat.models :as chat.models]
|
||||||
[status-im.constants :as constants]
|
|
||||||
[status-im.data-store.contacts :as contacts-store]))
|
[status-im.data-store.contacts :as contacts-store]))
|
||||||
|
|
||||||
(defn receive-contact-request
|
(defn receive-contact-request
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
(ns status-im.ui.screens.contacts.db
|
(ns status-im.ui.screens.contacts.db
|
||||||
(:require-macros [status-im.utils.db :refer [allowed-keys]])
|
(:require-macros [status-im.utils.db :refer [allowed-keys]])
|
||||||
(:require [cljs.spec.alpha :as spec]
|
(:require [cljs.spec.alpha :as spec]
|
||||||
[clojure.string :as string]
|
|
||||||
status-im.utils.db))
|
status-im.utils.db))
|
||||||
|
|
||||||
;;;; DB
|
;;;; DB
|
||||||
|
|
|
@ -1,23 +1,21 @@
|
||||||
(ns status-im.ui.screens.contacts.events
|
(ns status-im.ui.screens.contacts.events
|
||||||
(:require [clojure.set :as set]
|
(:require [cljs.reader :as reader]
|
||||||
[cljs.reader :as reader]
|
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
[status-im.utils.handlers :as handlers]
|
[status-im.utils.handlers :as handlers]
|
||||||
[status-im.utils.handlers-macro :as handlers-macro]
|
[status-im.utils.handlers-macro :as handlers-macro]
|
||||||
[status-im.utils.contacts :as utils.contacts]
|
[status-im.utils.contacts :as utils.contacts]
|
||||||
[status-im.constants :as constants]
|
|
||||||
[status-im.utils.identicon :as identicon]
|
|
||||||
[status-im.utils.gfycat.core :as gfycat.core]
|
|
||||||
[status-im.ui.screens.contacts.navigation]
|
|
||||||
[status-im.ui.screens.navigation :as navigation]
|
[status-im.ui.screens.navigation :as navigation]
|
||||||
[status-im.ui.screens.group.events :as group.events]
|
|
||||||
[status-im.chat.console :as console-chat]
|
|
||||||
[status-im.chat.events :as chat.events]
|
[status-im.chat.events :as chat.events]
|
||||||
[status-im.chat.models :as chat.models]
|
|
||||||
[status-im.transport.message.core :as transport]
|
[status-im.transport.message.core :as transport]
|
||||||
[status-im.transport.message.v1.contact :as message.v1.contact]
|
[status-im.transport.message.v1.contact :as message.v1.contact]
|
||||||
[status-im.ui.screens.add-new.new-chat.db :as new-chat.db]
|
[status-im.ui.screens.add-new.new-chat.db :as new-chat.db]
|
||||||
[status-im.data-store.contacts :as contacts-store]))
|
[status-im.data-store.contacts :as contacts-store]
|
||||||
|
[status-im.utils.js-resources :as js-res]))
|
||||||
|
|
||||||
|
(re-frame/reg-cofx
|
||||||
|
:get-default-contacts
|
||||||
|
(fn [coeffects _]
|
||||||
|
(assoc coeffects :default-contacts js-res/default-contacts)))
|
||||||
|
|
||||||
;;;; Handlers
|
;;;; Handlers
|
||||||
|
|
||||||
|
@ -93,26 +91,10 @@
|
||||||
fx
|
fx
|
||||||
(add-contact-and-open-chat contact-identity))))))
|
(add-contact-and-open-chat contact-identity))))))
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
|
||||||
:hide-contact
|
|
||||||
(fn [cofx [_ {:keys [whisper-identity] :as contact}]]
|
|
||||||
(update-contact {:whisper-identity whisper-identity
|
|
||||||
:pending? true}
|
|
||||||
cofx)))
|
|
||||||
|
|
||||||
;;used only by status-dev-cli
|
|
||||||
(handlers/register-handler-fx
|
|
||||||
:remove-contact
|
|
||||||
(fn [{:keys [db]} [_ whisper-identity]]
|
|
||||||
(when-let [contact (get-in db [:contacts/contacts whisper-identity])]
|
|
||||||
{:db (update db :contacts/contacts dissoc whisper-identity)
|
|
||||||
:data-store/tx [(contacts-store/delete-contact-tx whisper-identity)]})))
|
|
||||||
|
|
||||||
(handlers/register-handler-db
|
(handlers/register-handler-db
|
||||||
:open-contact-toggle-list
|
:open-contact-toggle-list
|
||||||
(fn [db [_ group-type]]
|
(fn [db _]
|
||||||
(-> (assoc db
|
(-> (assoc db
|
||||||
:group/group-type group-type
|
|
||||||
:group/selected-contacts #{}
|
:group/selected-contacts #{}
|
||||||
:new-chat-name "")
|
:new-chat-name "")
|
||||||
(navigation/navigate-to :contact-toggle-list))))
|
(navigation/navigate-to :contact-toggle-list))))
|
||||||
|
@ -120,7 +102,7 @@
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:open-chat-with-contact
|
:open-chat-with-contact
|
||||||
[(re-frame/inject-cofx :random-id)]
|
[(re-frame/inject-cofx :random-id)]
|
||||||
(fn [{:keys [db] :as cofx} [_ {:keys [whisper-identity] :as contact}]]
|
(fn [cofx [_ {:keys [whisper-identity]}]]
|
||||||
(handlers-macro/merge-fx cofx
|
(handlers-macro/merge-fx cofx
|
||||||
(navigation/navigate-to-clean :home)
|
(navigation/navigate-to-clean :home)
|
||||||
(add-contact whisper-identity)
|
(add-contact whisper-identity)
|
||||||
|
@ -129,6 +111,6 @@
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:add-contact-handler
|
:add-contact-handler
|
||||||
[(re-frame/inject-cofx :random-id)]
|
[(re-frame/inject-cofx :random-id)]
|
||||||
(fn [{{:contacts/keys [new-identity] :as db} :db :as cofx} _]
|
(fn [{{:contacts/keys [new-identity]} :db :as cofx} _]
|
||||||
(when (seq new-identity)
|
(when (seq new-identity)
|
||||||
(add-contact-and-open-chat new-identity cofx))))
|
(add-contact-and-open-chat new-identity cofx))))
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
(ns status-im.ui.screens.contacts.navigation
|
|
||||||
(:require [status-im.ui.screens.navigation :as nav]))
|
|
||||||
|
|
||||||
(defmethod nav/preload-data! :contact-list
|
|
||||||
[db [_ _ click-handler]]
|
|
||||||
(-> db
|
|
||||||
(assoc-in [:contacts/list-ui-props :edit?] false)
|
|
||||||
(assoc-in [:contacts/ui-props :edit?] false)
|
|
||||||
(assoc :contacts/click-handler click-handler)))
|
|
||||||
|
|
||||||
(defmethod nav/preload-data! :contact-list-modal
|
|
||||||
[db [_ _ {:keys [handler action params]}]]
|
|
||||||
(assoc db :contacts/click-handler handler
|
|
||||||
:contacts/click-action action
|
|
||||||
:contacts/click-params params))
|
|
|
@ -1,95 +0,0 @@
|
||||||
(ns status-im.ui.screens.contacts.styles
|
|
||||||
(:require-macros [status-im.utils.styles :refer [defnstyle defstyle]])
|
|
||||||
(:require [status-im.ui.components.styles :as common]))
|
|
||||||
|
|
||||||
(def toolbar-actions
|
|
||||||
{:flex-direction :row})
|
|
||||||
|
|
||||||
(def contact-groups
|
|
||||||
{:flex 1
|
|
||||||
:background-color common/color-light-gray})
|
|
||||||
|
|
||||||
(def contacts-list-container
|
|
||||||
{:flex 1})
|
|
||||||
|
|
||||||
(def contacts-list
|
|
||||||
{:background-color common/color-white})
|
|
||||||
|
|
||||||
(def contacts-list-modal
|
|
||||||
{:background-color common/color-light-gray})
|
|
||||||
|
|
||||||
(def empty-contact-groups
|
|
||||||
(merge contact-groups
|
|
||||||
{:align-items :center
|
|
||||||
:justify-content :center}))
|
|
||||||
|
|
||||||
(def empty-contacts-icon
|
|
||||||
{:height 62
|
|
||||||
:width 62})
|
|
||||||
|
|
||||||
(def empty-contacts-text
|
|
||||||
{:margin-top 12
|
|
||||||
:font-size 16
|
|
||||||
:color common/color-gray2})
|
|
||||||
|
|
||||||
(def contact-group-count
|
|
||||||
{:margin-left 8
|
|
||||||
:opacity 0.6})
|
|
||||||
|
|
||||||
(defstyle show-all
|
|
||||||
{:flex-direction :row
|
|
||||||
:align-items :center
|
|
||||||
:background-color common/color-white
|
|
||||||
:padding-left 72
|
|
||||||
:android {:height 56}
|
|
||||||
:ios {:height 64}})
|
|
||||||
|
|
||||||
(defstyle show-all-text
|
|
||||||
{:android {:font-size 14
|
|
||||||
:color common/color-blue
|
|
||||||
:letter-spacing 0.5}
|
|
||||||
:ios {:font-size 16
|
|
||||||
:color common/color-gray4
|
|
||||||
:letter-spacing -0.2}})
|
|
||||||
|
|
||||||
(def option-inner-image
|
|
||||||
{:width 24
|
|
||||||
:height 18
|
|
||||||
:top 16
|
|
||||||
:left 13})
|
|
||||||
|
|
||||||
(def group-icon
|
|
||||||
(assoc option-inner-image
|
|
||||||
:tint-color common/color-gray))
|
|
||||||
|
|
||||||
; New contact
|
|
||||||
|
|
||||||
(def contact-form-container
|
|
||||||
{:flex 1
|
|
||||||
:color :white
|
|
||||||
:background-color :white})
|
|
||||||
|
|
||||||
(def gradient-background
|
|
||||||
{:position :absolute
|
|
||||||
:top 0
|
|
||||||
:right 0
|
|
||||||
:bottom 0
|
|
||||||
:left 0})
|
|
||||||
|
|
||||||
(def form-container
|
|
||||||
{:margin-left 16
|
|
||||||
:margin-top 8
|
|
||||||
:height 72})
|
|
||||||
|
|
||||||
(def address-explication-container
|
|
||||||
{:flex 1
|
|
||||||
:margin-top 30
|
|
||||||
:padding-left 16
|
|
||||||
:padding-right 16})
|
|
||||||
|
|
||||||
(def address-explication
|
|
||||||
{:text-align :center
|
|
||||||
:color common/color-gray})
|
|
||||||
|
|
||||||
(def qr-input
|
|
||||||
{:margin-right 42})
|
|
|
@ -1,6 +1,5 @@
|
||||||
(ns status-im.ui.screens.contacts.subs
|
(ns status-im.ui.screens.contacts.subs
|
||||||
(:require [clojure.string :as string]
|
(:require [re-frame.core :refer [reg-sub subscribe]]
|
||||||
[re-frame.core :refer [reg-sub subscribe]]
|
|
||||||
[status-im.utils.ethereum.core :as ethereum]
|
[status-im.utils.ethereum.core :as ethereum]
|
||||||
[status-im.utils.identicon :as identicon]
|
[status-im.utils.identicon :as identicon]
|
||||||
[status-im.utils.contacts :as utils.contacts]))
|
[status-im.utils.contacts :as utils.contacts]))
|
||||||
|
@ -59,12 +58,6 @@
|
||||||
(let [group-contacts' (into #{} group-contacts)]
|
(let [group-contacts' (into #{} group-contacts)]
|
||||||
(filter #(group-contacts' (:whisper-identity %)) contacts)))
|
(filter #(group-contacts' (:whisper-identity %)) contacts)))
|
||||||
|
|
||||||
(reg-sub :get-all-added-group-contacts
|
|
||||||
:<- [:all-added-contacts]
|
|
||||||
:<- [:get-contact-groups]
|
|
||||||
(fn [[contacts contact-groups] [_ group-id]]
|
|
||||||
(filter-group-contacts (get-in contact-groups [group-id :contacts]) contacts)))
|
|
||||||
|
|
||||||
(reg-sub :get-contact-by-identity
|
(reg-sub :get-contact-by-identity
|
||||||
:<- [:get-contacts]
|
:<- [:get-contacts]
|
||||||
(fn [contacts [_ identity]]
|
(fn [contacts [_ identity]]
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
(ns status-im.ui.screens.contacts.views
|
|
||||||
(:require-macros [status-im.utils.views :refer [defview letsubs]])
|
|
||||||
(:require [re-frame.core :refer [dispatch]]
|
|
||||||
[status-im.ui.components.react :refer [view text touchable-highlight scroll-view]]
|
|
||||||
[status-im.ui.components.contact.contact :refer [contact-view]]
|
|
||||||
[status-im.utils.platform :refer [platform-specific ios? android?]]
|
|
||||||
[status-im.utils.utils :as u]
|
|
||||||
[status-im.i18n :refer [label]]
|
|
||||||
[status-im.ui.components.styles :refer [color-blue]]))
|
|
||||||
|
|
||||||
(defn contact-options [{:keys [unremovable?] :as contact} group]
|
|
||||||
(let [delete-contact-opt {:action #(u/show-confirmation
|
|
||||||
(str (label :t/delete-contact) "?") (label :t/delete-contact-confirmation)
|
|
||||||
(label :t/delete)
|
|
||||||
(fn [] (dispatch [:hide-contact contact])))
|
|
||||||
:label (label :t/delete-contact)
|
|
||||||
:destructive? true}
|
|
||||||
options (if unremovable? [] [delete-contact-opt])]
|
|
||||||
(if group
|
|
||||||
(conj options
|
|
||||||
{:action #(dispatch [:remove-contact-from-group
|
|
||||||
(:whisper-identity contact)
|
|
||||||
(:group-id group)])
|
|
||||||
:label (label :t/remove-from-group)})
|
|
||||||
options)))
|
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
:navigation-stack '()
|
:navigation-stack '()
|
||||||
:contacts/contacts {}
|
:contacts/contacts {}
|
||||||
:qr-codes {}
|
:qr-codes {}
|
||||||
:group/contact-groups {}
|
|
||||||
:group/selected-contacts #{}
|
:group/selected-contacts #{}
|
||||||
:chats {}
|
:chats {}
|
||||||
:current-chat-id nil
|
:current-chat-id nil
|
||||||
|
@ -148,11 +147,7 @@
|
||||||
:contacts/click-handler
|
:contacts/click-handler
|
||||||
:contacts/click-action
|
:contacts/click-action
|
||||||
:contacts/click-params
|
:contacts/click-params
|
||||||
:group/contact-groups
|
|
||||||
:group/contact-group-id
|
|
||||||
:group/group-type
|
|
||||||
:group/selected-contacts
|
:group/selected-contacts
|
||||||
:group/groups-order
|
|
||||||
:accounts/accounts
|
:accounts/accounts
|
||||||
:accounts/create
|
:accounts/create
|
||||||
:accounts/recover
|
:accounts/recover
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
status-im.chat.events
|
status-im.chat.events
|
||||||
status-im.commands.handlers.jail
|
status-im.commands.handlers.jail
|
||||||
status-im.commands.events.loading
|
status-im.commands.events.loading
|
||||||
status-im.commands.handlers.debug
|
|
||||||
status-im.network.events
|
status-im.network.events
|
||||||
status-im.transport.handlers
|
status-im.transport.handlers
|
||||||
status-im.protocol.handlers
|
status-im.protocol.handlers
|
||||||
|
@ -309,10 +308,8 @@
|
||||||
[:fetch-web3-node-version]
|
[:fetch-web3-node-version]
|
||||||
[:initialize-sync-listener]
|
[:initialize-sync-listener]
|
||||||
[:load-contacts]
|
[:load-contacts]
|
||||||
[:load-contact-groups]
|
|
||||||
[:initialize-chats]
|
[:initialize-chats]
|
||||||
[:initialize-browsers]
|
[:initialize-browsers]
|
||||||
[:initialize-debugging {:address address}]
|
|
||||||
[:send-account-update-if-needed]
|
[:send-account-update-if-needed]
|
||||||
[:process-pending-messages]
|
[:process-pending-messages]
|
||||||
[:update-wallet]
|
[:update-wallet]
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
[status-im.ui.components.react :as react]
|
[status-im.ui.components.react :as react]
|
||||||
[status-im.ui.components.status-bar.view :refer [status-bar]]
|
[status-im.ui.components.status-bar.view :refer [status-bar]]
|
||||||
[status-im.ui.components.toolbar.view :as toolbar]
|
[status-im.ui.components.toolbar.view :as toolbar]
|
||||||
[status-im.ui.screens.group.styles :as styles]
|
[status-im.ui.screens.group.styles :as styles]))
|
||||||
[status-im.ui.screens.contacts.styles :as contacts.styles]))
|
|
||||||
|
|
||||||
(defn- on-toggle [checked? whisper-identity]
|
(defn- on-toggle [checked? whisper-identity]
|
||||||
(let [action (if checked? :deselect-contact :select-contact)]
|
(let [action (if checked? :deselect-contact :select-contact)]
|
||||||
|
@ -35,40 +34,25 @@
|
||||||
|
|
||||||
(defn toggle-list [contacts render-function]
|
(defn toggle-list [contacts render-function]
|
||||||
[react/view {:flex 1}
|
[react/view {:flex 1}
|
||||||
[list/flat-list {:style contacts.styles/contacts-list
|
[list/flat-list {:style styles/contacts-list
|
||||||
:data contacts
|
:data contacts
|
||||||
:key-fn :address
|
:key-fn :address
|
||||||
:render-fn render-function
|
:render-fn render-function
|
||||||
:keyboardShouldPersistTaps :always}]])
|
:keyboardShouldPersistTaps :always}]])
|
||||||
|
|
||||||
|
;; Start group chat
|
||||||
(defview contact-toggle-list []
|
(defview contact-toggle-list []
|
||||||
(letsubs [contacts [:all-added-people-contacts]
|
(letsubs [contacts [:all-added-people-contacts]
|
||||||
selected-contacts-count [:selected-contacts-count]
|
selected-contacts-count [:selected-contacts-count]]
|
||||||
group-type [:get-group-type]]
|
|
||||||
[react/keyboard-avoiding-view {:style styles/group-container}
|
[react/keyboard-avoiding-view {:style styles/group-container}
|
||||||
[status-bar]
|
[status-bar]
|
||||||
[toggle-list-toolbar {:handler #(re-frame/dispatch [:navigate-to :new-group])
|
[toggle-list-toolbar {:handler #(re-frame/dispatch [:navigate-to :new-group])
|
||||||
:label (i18n/label :t/next)
|
:label (i18n/label :t/next)
|
||||||
:count (pos? selected-contacts-count)}
|
:count (pos? selected-contacts-count)}
|
||||||
(i18n/label (if (= group-type :contact-group)
|
(i18n/label :t/group-chat)]
|
||||||
:t/new-group
|
|
||||||
:t/group-chat))]
|
|
||||||
[toggle-list contacts group-toggle-contact]]))
|
|
||||||
|
|
||||||
(defview add-contacts-toggle-list []
|
|
||||||
(letsubs [contacts [:all-group-not-added-contacts]
|
|
||||||
group [:get-contact-group]
|
|
||||||
selected-contacts-count [:selected-contacts-count]]
|
|
||||||
[react/keyboard-avoiding-view {:style styles/group-container}
|
|
||||||
[status-bar]
|
|
||||||
[toggle-list-toolbar {:count selected-contacts-count
|
|
||||||
:handler #(do
|
|
||||||
(re-frame/dispatch [:add-selected-contacts-to-group])
|
|
||||||
(re-frame/dispatch [:navigate-back]))
|
|
||||||
:label (i18n/label :t/save)}
|
|
||||||
(:name group)]
|
|
||||||
[toggle-list contacts group-toggle-contact]]))
|
[toggle-list contacts group-toggle-contact]]))
|
||||||
|
|
||||||
|
;; Add participants to existing group chat
|
||||||
(defview add-participants-toggle-list []
|
(defview add-participants-toggle-list []
|
||||||
(letsubs [contacts [:get-all-contacts-not-in-current-chat]
|
(letsubs [contacts [:get-all-contacts-not-in-current-chat]
|
||||||
{:keys [name]} [:get-current-chat]
|
{:keys [name]} [:get-current-chat]
|
||||||
|
|
|
@ -10,12 +10,10 @@
|
||||||
[status-im.data-store.chats :as chats-store]
|
[status-im.data-store.chats :as chats-store]
|
||||||
[status-im.data-store.messages :as messages-store]))
|
[status-im.data-store.messages :as messages-store]))
|
||||||
|
|
||||||
;;;; Handlers
|
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:show-group-chat-profile
|
:show-group-chat-profile
|
||||||
[re-frame/trim-v]
|
[re-frame/trim-v]
|
||||||
(fn [{:keys [db] :as cofx} [chat-id]]
|
(fn [{:keys [db]} [chat-id]]
|
||||||
{:db (-> db
|
{:db (-> db
|
||||||
(assoc :new-chat-name (get-in db [:chats chat-id :name])
|
(assoc :new-chat-name (get-in db [:chats chat-id :name])
|
||||||
:group/group-type :chat-group)
|
:group/group-type :chat-group)
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
(ns status-im.ui.screens.group.chat-settings.subs
|
|
||||||
(:require [re-frame.core :refer [reg-sub]]
|
|
||||||
[status-im.constants :refer [max-chat-name-length]]))
|
|
||||||
|
|
||||||
(reg-sub
|
|
||||||
:selected-participant
|
|
||||||
(fn [db]
|
|
||||||
(let [identity (first (:selected-participants db))]
|
|
||||||
(get-in db [:contacts/contacts identity]))))
|
|
||||||
|
|
||||||
(defn get-chat-name-validation-messages [chat-name]
|
|
||||||
(filter some?
|
|
||||||
(list (when (zero? (count chat-name))
|
|
||||||
"Chat name can't be empty")
|
|
||||||
(when (< max-chat-name-length (count chat-name))
|
|
||||||
"Chat name is too long"))))
|
|
||||||
|
|
||||||
(reg-sub
|
|
||||||
:new-chat-name
|
|
||||||
(fn [db]
|
|
||||||
(:new-chat-name db)))
|
|
||||||
|
|
||||||
(reg-sub
|
|
||||||
:new-chat-name-validation-messages
|
|
||||||
:<- [:new-chat-name]
|
|
||||||
(fn [chat-name]
|
|
||||||
(get-chat-name-validation-messages chat-name)))
|
|
||||||
|
|
||||||
(reg-sub
|
|
||||||
:new-chat-name-valid?
|
|
||||||
:<- [:new-chat-name]
|
|
||||||
(fn [chat-name]
|
|
||||||
(zero? (count (get-chat-name-validation-messages chat-name)))))
|
|
|
@ -1,33 +1,5 @@
|
||||||
(ns status-im.ui.screens.group.db
|
(ns status-im.ui.screens.group.db
|
||||||
(:require-macros [status-im.utils.db :refer [allowed-keys]])
|
(:require-macros [status-im.utils.db :refer [allowed-keys]])
|
||||||
(:require [cljs.spec.alpha :as spec]
|
(:require [cljs.spec.alpha :as spec]))
|
||||||
status-im.utils.db
|
|
||||||
[status-im.constants :refer [console-chat-id]]
|
|
||||||
[clojure.string :as string]
|
|
||||||
[status-im.utils.homoglyph :as utils]))
|
|
||||||
|
|
||||||
(spec/def ::name :global/not-empty-string)
|
|
||||||
;;;; DB
|
|
||||||
|
|
||||||
(spec/def :group/group-id :global/not-empty-string)
|
|
||||||
(spec/def :group/name :global/not-empty-string)
|
|
||||||
(spec/def :group/timestamp int?)
|
|
||||||
(spec/def :group/pending? boolean?)
|
|
||||||
(spec/def :group/order int?)
|
|
||||||
|
|
||||||
(spec/def :group/contact :global/not-empty-string)
|
|
||||||
|
|
||||||
(spec/def :group/contacts (spec/nilable (spec/* :group/contact)))
|
|
||||||
|
|
||||||
(spec/def :group/contact-group (allowed-keys
|
|
||||||
:req-un [:group/group-id :group/name :group/timestamp
|
|
||||||
:group/order :group/contacts]
|
|
||||||
:opt-un [:group/pending?]))
|
|
||||||
|
|
||||||
(spec/def :group/contact-groups (spec/nilable (spec/map-of :global/not-empty-string :group/contact-group)))
|
|
||||||
;;used during editing contact group
|
|
||||||
(spec/def :group/contact-group-id (spec/nilable string?))
|
|
||||||
(spec/def :group/group-type (spec/nilable #{:chat-group :contact-group}))
|
|
||||||
(spec/def :group/selected-contacts (spec/nilable (spec/* string?)))
|
(spec/def :group/selected-contacts (spec/nilable (spec/* string?)))
|
||||||
;;list of group ids
|
|
||||||
(spec/def :group/groups-order (spec/nilable (spec/* string?)))
|
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
(ns status-im.ui.screens.group.edit-contacts.views
|
|
||||||
(:require-macros [status-im.utils.views :refer [defview letsubs]])
|
|
||||||
(:require [re-frame.core :as re-frame]
|
|
||||||
[status-im.ui.components.contact.contact :refer [contact-view]]
|
|
||||||
[status-im.ui.components.list.views :as list]
|
|
||||||
[status-im.ui.components.react :as react]
|
|
||||||
[status-im.ui.components.status-bar.view :refer [status-bar]]
|
|
||||||
[status-im.ui.components.toolbar.view :as toolbar]
|
|
||||||
[status-im.ui.screens.group.styles :as styles]
|
|
||||||
[status-im.i18n :as i18n]))
|
|
||||||
|
|
||||||
(defn contacts-list [contacts extended? extend-options]
|
|
||||||
[react/view {:flex 1}
|
|
||||||
[list/flat-list {:data contacts
|
|
||||||
:enableEmptySections true
|
|
||||||
:key-fn :address
|
|
||||||
:render-fn (fn [contact]
|
|
||||||
[contact-view {:contact contact
|
|
||||||
:extended? extended?
|
|
||||||
:extend-options (extend-options contact)}])
|
|
||||||
:bounces false
|
|
||||||
:keyboardShouldPersistTaps :always
|
|
||||||
:footer list/default-footer
|
|
||||||
:header list/default-header}]])
|
|
||||||
|
|
||||||
(defn chat-extended-options [item]
|
|
||||||
[{:action #(re-frame/dispatch [:remove-group-chat-participants #{(:whisper-identity item)}])
|
|
||||||
:label (i18n/label :t/remove)}])
|
|
||||||
|
|
||||||
(defn contact-extended-options [group-id]
|
|
||||||
(fn [item]
|
|
||||||
[{:action #(re-frame/dispatch [:remove-contact-from-group
|
|
||||||
(:whisper-identity item)
|
|
||||||
group-id])
|
|
||||||
:accessibility-label :remove-button
|
|
||||||
:label (i18n/label :t/remove-from-group)}]))
|
|
||||||
|
|
||||||
(defview contacts-list-view [group-id]
|
|
||||||
(letsubs [contacts [:get-all-added-group-contacts group-id]]
|
|
||||||
[contacts-list
|
|
||||||
contacts
|
|
||||||
true
|
|
||||||
(contact-extended-options group-id)]))
|
|
||||||
|
|
||||||
(defview edit-contact-group-contact-list []
|
|
||||||
(letsubs [group [:get-contact-group]]
|
|
||||||
[react/view styles/group-container
|
|
||||||
[status-bar]
|
|
||||||
[toolbar/simple-toolbar (:name group)]
|
|
||||||
[contacts-list-view (:group-id group)]]))
|
|
|
@ -1,21 +1,6 @@
|
||||||
(ns status-im.ui.screens.group.events
|
(ns status-im.ui.screens.group.events
|
||||||
(:require [clojure.set :as set]
|
(:require [status-im.utils.handlers :as handlers]
|
||||||
[re-frame.core :as re-frame]
|
[status-im.ui.screens.group.navigation]))
|
||||||
[status-im.utils.js-resources :as js-res]
|
|
||||||
[status-im.utils.handlers :as handlers]
|
|
||||||
[status-im.ui.screens.group.navigation]
|
|
||||||
[status-im.data-store.contact-groups :as contact-groups-store]))
|
|
||||||
|
|
||||||
;;;; COFX
|
|
||||||
|
|
||||||
(re-frame/reg-cofx
|
|
||||||
:get-default-contacts-and-groups
|
|
||||||
(fn [coeffects _]
|
|
||||||
(assoc coeffects
|
|
||||||
:default-contacts js-res/default-contacts
|
|
||||||
:default-groups js-res/default-contact-groups)))
|
|
||||||
|
|
||||||
;;;; Handlers
|
|
||||||
|
|
||||||
(handlers/register-handler-db
|
(handlers/register-handler-db
|
||||||
:deselect-contact
|
:deselect-contact
|
||||||
|
@ -36,68 +21,3 @@
|
||||||
:select-participant
|
:select-participant
|
||||||
(fn [db [_ id]]
|
(fn [db [_ id]]
|
||||||
(update db :selected-participants conj id)))
|
(update db :selected-participants conj id)))
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
|
||||||
:create-new-contact-group
|
|
||||||
[re-frame/trim-v (re-frame/inject-cofx :now) (re-frame/inject-cofx :random-id)]
|
|
||||||
(fn [{{:group/keys [contact-groups selected-contacts] :as db} :db group-id :random-id now :now} [group-name]]
|
|
||||||
(let [new-group {:group-id group-id
|
|
||||||
:name group-name
|
|
||||||
:order (count contact-groups)
|
|
||||||
:timestamp now
|
|
||||||
:contacts selected-contacts}]
|
|
||||||
{:db (assoc-in db [:group/contact-groups group-id] new-group)
|
|
||||||
:data-store/tx [(contact-groups-store/save-contact-group-tx new-group)]})))
|
|
||||||
|
|
||||||
(defn add-default-groups
|
|
||||||
[{:keys [db now default-groups]}]
|
|
||||||
(let [new-groups (into {}
|
|
||||||
(map (fn [[id props]]
|
|
||||||
(let [group-id (name id)]
|
|
||||||
[group-id {:group-id group-id
|
|
||||||
:name (-> props :name :en)
|
|
||||||
:order 0
|
|
||||||
:timestamp now
|
|
||||||
:contacts (:contacts props)}])))
|
|
||||||
default-groups)
|
|
||||||
existing-groups (:group/contact-groups db)
|
|
||||||
groups-to-add (select-keys new-groups (set/difference (set (keys new-groups))
|
|
||||||
(set (keys existing-groups))))]
|
|
||||||
{:db (update db :group/contact-groups merge groups-to-add)
|
|
||||||
:data-store/tx [(contact-groups-store/save-contact-groups-tx
|
|
||||||
(vals groups-to-add))]}))
|
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
|
||||||
:load-contact-groups
|
|
||||||
[(re-frame/inject-cofx :data-store/get-all-contact-groups)]
|
|
||||||
(fn [{:keys [db all-contact-groups]} _]
|
|
||||||
{:db (assoc db :group/contact-groups all-contact-groups)}))
|
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
|
||||||
:set-contact-group-name
|
|
||||||
(fn [{{:keys [new-chat-name] :group/keys [contact-group-id] :as db} :db} _]
|
|
||||||
{:db (assoc-in db
|
|
||||||
[:group/contact-groups contact-group-id :name]
|
|
||||||
new-chat-name)
|
|
||||||
:data-store/tx [(contact-groups-store/save-contact-group-tx
|
|
||||||
{:group-id contact-group-id
|
|
||||||
:name new-chat-name})]}))
|
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
|
||||||
:add-selected-contacts-to-group
|
|
||||||
(fn [{{:group/keys [contact-groups contact-group-id selected-contacts] :as db} :db} _]
|
|
||||||
{:db (update-in db
|
|
||||||
[:group/contact-groups contact-group-id :contacts]
|
|
||||||
#(into [] (set (concat % selected-contacts))))
|
|
||||||
:data-store/tx [(contact-groups-store/add-contacts-to-contact-group-tx
|
|
||||||
contact-group-id selected-contacts)]}))
|
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
|
||||||
:remove-contact-from-group
|
|
||||||
[re-frame/trim-v]
|
|
||||||
(fn [{:keys [db]} [whisper-identity group-id]]
|
|
||||||
(let [group (-> db
|
|
||||||
(get-in [:group/contact-groups group-id])
|
|
||||||
(update :contacts (partial remove #(= whisper-identity %))))]
|
|
||||||
{:db (assoc-in db [:group/contact-groups group-id] group)
|
|
||||||
:data-store/tx [(contact-groups-store/save-contact-group-tx group)]})))
|
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
(ns status-im.ui.screens.group.navigation
|
(ns status-im.ui.screens.group.navigation
|
||||||
(:require [status-im.ui.screens.navigation :as nav]))
|
(:require [status-im.ui.screens.navigation :as nav]))
|
||||||
|
|
||||||
(defmethod nav/preload-data! :add-contacts-toggle-list
|
|
||||||
[db _]
|
|
||||||
(assoc db :group/selected-contacts #{}))
|
|
||||||
|
|
||||||
(defmethod nav/preload-data! :add-participants-toggle-list
|
(defmethod nav/preload-data! :add-participants-toggle-list
|
||||||
[db _]
|
[db _]
|
||||||
(assoc db :selected-participants #{}))
|
(assoc db :selected-participants #{}))
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
(ns status-im.ui.screens.group.styles
|
(ns status-im.ui.screens.group.styles
|
||||||
(:require-macros [status-im.utils.styles :refer [defstyle]])
|
(:require-macros [status-im.utils.styles :refer [defstyle]])
|
||||||
(:require [status-im.ui.components.styles :as common]))
|
(:require [status-im.ui.components.colors :as colors]))
|
||||||
|
|
||||||
(defn toolbar-icon [enabled?]
|
(defn toolbar-icon [enabled?]
|
||||||
{:width 20
|
{:width 20
|
||||||
|
@ -10,163 +10,10 @@
|
||||||
(def group-container
|
(def group-container
|
||||||
{:flex 1
|
{:flex 1
|
||||||
:flex-direction :column
|
:flex-direction :column
|
||||||
:background-color common/color-white})
|
:background-color colors/white})
|
||||||
|
|
||||||
(defstyle reorder-list-container
|
|
||||||
{:flex 1
|
|
||||||
:android {:padding-top 16}})
|
|
||||||
|
|
||||||
(def add-button-container
|
|
||||||
{:margin-left 16})
|
|
||||||
|
|
||||||
(defstyle group-name-text
|
|
||||||
{:letter-spacing -0.1
|
|
||||||
:color common/color-gray4
|
|
||||||
:ios {:font-size 13}
|
|
||||||
:android {:font-size 12}})
|
|
||||||
|
|
||||||
(defstyle members-text
|
|
||||||
{:color common/color-gray4
|
|
||||||
:ios {:letter-spacing -0.2
|
|
||||||
:font-size 16}
|
|
||||||
:android {:font-size 14}})
|
|
||||||
|
|
||||||
(defstyle members-text-count
|
|
||||||
{:margin-left 8
|
|
||||||
:color common/color-gray4
|
|
||||||
:opacity 0.6
|
|
||||||
:ios {:letter-spacing -0.2
|
|
||||||
:font-size 16}
|
|
||||||
:android {:font-size 14}})
|
|
||||||
|
|
||||||
(def add-container
|
|
||||||
{:flex-direction :row
|
|
||||||
:align-items :center
|
|
||||||
:height 64
|
|
||||||
:margin-top 12})
|
|
||||||
|
|
||||||
(defstyle settings-icon-container
|
|
||||||
{:width 40
|
|
||||||
:height 40
|
|
||||||
:align-items :center
|
|
||||||
:justify-content :center
|
|
||||||
:ios {:background-color "#628fe333"
|
|
||||||
:border-radius 50}})
|
|
||||||
(def add-icon
|
|
||||||
{:align-items :center
|
|
||||||
:width 24
|
|
||||||
:height 24})
|
|
||||||
|
|
||||||
(defstyle add-group-text
|
|
||||||
{:color common/color-light-blue
|
|
||||||
:ios {:color common/color-light-blue
|
|
||||||
:letter-spacing -0.2
|
|
||||||
:font-size 17
|
|
||||||
:line-height 20}
|
|
||||||
:android {:letter-spacing 0.5
|
|
||||||
:font-size 16}})
|
|
||||||
|
|
||||||
(def settings-group-text
|
|
||||||
add-group-text)
|
|
||||||
|
|
||||||
(def settings-group-text-container
|
|
||||||
{:padding-left 16})
|
|
||||||
|
|
||||||
(def delete-group-text
|
|
||||||
(merge add-group-text
|
|
||||||
{:color common/color-light-red}))
|
|
||||||
|
|
||||||
(defstyle delete-group-prompt-text
|
|
||||||
{:color common/color-gray4
|
|
||||||
:padding-top 5
|
|
||||||
:ios {:font-size 14
|
|
||||||
:letter-spacing -0.2}
|
|
||||||
:android {:font-size 12}})
|
|
||||||
|
|
||||||
(defstyle contact-container
|
|
||||||
{:flex-direction :row
|
|
||||||
:justify-content :center
|
|
||||||
:align-items :center
|
|
||||||
:ios {:height 63}
|
|
||||||
:android {:height 56}})
|
|
||||||
|
|
||||||
(def contact
|
(def contact
|
||||||
{:padding-left 0})
|
{:padding-left 0})
|
||||||
|
|
||||||
(defstyle settings-group-container
|
(def contacts-list
|
||||||
{:ios {:margin-top 25}
|
{:background-color colors/white})
|
||||||
:android {:margin-top 23}})
|
|
||||||
|
|
||||||
(defstyle settings-group-item
|
|
||||||
{:padding-left 16
|
|
||||||
:flex-direction :row
|
|
||||||
:align-items :center
|
|
||||||
:ios {:height 64}
|
|
||||||
:android {:height 56}})
|
|
||||||
|
|
||||||
(defstyle delete-icon-container
|
|
||||||
{:width 40
|
|
||||||
:height 40
|
|
||||||
:align-items :center
|
|
||||||
:justify-content :center
|
|
||||||
:ios {:background-color "#d84b4b33"
|
|
||||||
:border-radius 50}})
|
|
||||||
|
|
||||||
(def order-item-container
|
|
||||||
{:background-color common/color-white})
|
|
||||||
|
|
||||||
(defstyle order-item-inner-container
|
|
||||||
{:flex-direction :row
|
|
||||||
:align-items :center
|
|
||||||
:android {:padding-top 17
|
|
||||||
:padding-bottom 15
|
|
||||||
:min-height 56
|
|
||||||
:background-color common/color-white}
|
|
||||||
:ios {:padding-vertical 22
|
|
||||||
:min-height 63}})
|
|
||||||
|
|
||||||
(defstyle order-item-label
|
|
||||||
{:padding-left 16
|
|
||||||
:flex-shrink 1
|
|
||||||
:android {:font-size 16
|
|
||||||
:color common/color-black
|
|
||||||
:line-height 24}
|
|
||||||
:ios {:font-size 17
|
|
||||||
:line-height 20
|
|
||||||
:letter-spacing -0.2}})
|
|
||||||
|
|
||||||
(defstyle order-item-contacts
|
|
||||||
{:padding-left 8
|
|
||||||
:color common/color-gray4
|
|
||||||
:ios {:font-size 17
|
|
||||||
:line-height 20
|
|
||||||
:letter-spacing -0.2}
|
|
||||||
:android {:font-size 16
|
|
||||||
:line-height 24}})
|
|
||||||
|
|
||||||
(defstyle order-item-icon
|
|
||||||
{:android {:padding-horizontal 16}
|
|
||||||
:ios {:padding-horizontal 20}})
|
|
||||||
|
|
||||||
(def order-item-separator-wrapper
|
|
||||||
{:background-color common/color-white})
|
|
||||||
|
|
||||||
(def order-item-separator
|
|
||||||
{:height 1
|
|
||||||
:background-color common/color-gray5
|
|
||||||
:ios {:margin-left 16
|
|
||||||
:opacity 0.5}})
|
|
||||||
|
|
||||||
(defstyle toolbar-container
|
|
||||||
{:flex 1
|
|
||||||
:android {:padding-left 18}
|
|
||||||
:ios {:align-items :center}})
|
|
||||||
|
|
||||||
(def separator
|
|
||||||
{:background-color common/color-gray5
|
|
||||||
:height 1
|
|
||||||
:opacity 0.5})
|
|
||||||
|
|
||||||
(def list-view-container
|
|
||||||
{:flex 1
|
|
||||||
:margin-top 10})
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
(ns status-im.ui.screens.group.subs
|
(ns status-im.ui.screens.group.subs
|
||||||
(:require [re-frame.core :refer [reg-sub subscribe]]
|
(:require [re-frame.core :refer [reg-sub]]
|
||||||
[status-im.utils.subs :as utils]))
|
[status-im.utils.subs :as utils]))
|
||||||
|
|
||||||
(reg-sub
|
(reg-sub
|
||||||
|
@ -35,25 +35,3 @@
|
||||||
:<- [:all-added-contacts]
|
:<- [:all-added-contacts]
|
||||||
(fn [[selected-contacts added-contacts]]
|
(fn [[selected-contacts added-contacts]]
|
||||||
(filter-contacts selected-contacts added-contacts)))
|
(filter-contacts selected-contacts added-contacts)))
|
||||||
|
|
||||||
(reg-sub
|
|
||||||
:get-contact-groups
|
|
||||||
(fn [db]
|
|
||||||
(:group/contact-groups db)))
|
|
||||||
|
|
||||||
(reg-sub
|
|
||||||
:get-contact-group-id
|
|
||||||
(fn [db]
|
|
||||||
(:group/contact-group-id db)))
|
|
||||||
|
|
||||||
(reg-sub
|
|
||||||
:get-contact-group
|
|
||||||
:<- [:get-contact-groups]
|
|
||||||
:<- [:get-contact-group-id]
|
|
||||||
(fn [[groups group-id]]
|
|
||||||
(get groups group-id)))
|
|
||||||
|
|
||||||
(reg-sub
|
|
||||||
:get-group-type
|
|
||||||
(fn [db]
|
|
||||||
(:group/group-type db)))
|
|
||||||
|
|
|
@ -10,8 +10,7 @@
|
||||||
[status-im.utils.platform :as platform]
|
[status-im.utils.platform :as platform]
|
||||||
[status-im.ui.components.contact.contact :as contact]
|
[status-im.ui.components.contact.contact :as contact]
|
||||||
[status-im.ui.screens.add-new.styles :as add-new.styles]
|
[status-im.ui.screens.add-new.styles :as add-new.styles]
|
||||||
[status-im.ui.screens.group.styles :as styles]
|
[status-im.ui.screens.group.styles :as styles]))
|
||||||
[status-im.ui.screens.group.db :as v]))
|
|
||||||
|
|
||||||
(views/defview group-name-view []
|
(views/defview group-name-view []
|
||||||
(views/letsubs [new-group-name [:get :new-chat-name]]
|
(views/letsubs [new-group-name [:get :new-chat-name]]
|
||||||
|
@ -44,10 +43,11 @@
|
||||||
:accessibility-label :create-button}
|
:accessibility-label :create-button}
|
||||||
(i18n/label :t/create)])))])
|
(i18n/label :t/create)])))])
|
||||||
|
|
||||||
|
;; New Group Chat
|
||||||
(views/defview new-group []
|
(views/defview new-group []
|
||||||
(views/letsubs [contacts [:selected-group-contacts]
|
(views/letsubs [contacts [:selected-group-contacts]
|
||||||
group-name [:get :new-chat-name]]
|
group-name [:get :new-chat-name]]
|
||||||
(let [save-btn-enabled? (and (spec/valid? ::v/name group-name) (pos? (count contacts)))]
|
(let [save-btn-enabled? (and (spec/valid? :global/not-empty-string group-name) (pos? (count contacts)))]
|
||||||
[react/keyboard-avoiding-view (merge {:behavior :padding}
|
[react/keyboard-avoiding-view (merge {:behavior :padding}
|
||||||
styles/group-container)
|
styles/group-container)
|
||||||
[status-bar/status-bar]
|
[status-bar/status-bar]
|
||||||
|
@ -59,5 +59,5 @@
|
||||||
:key-fn :address
|
:key-fn :address
|
||||||
:render-fn render-contact
|
:render-fn render-contact
|
||||||
:bounces false
|
:bounces false
|
||||||
:keyboardShouldPersistTaps :always
|
:keyboard-should-persist-taps :always
|
||||||
:enableEmptySections true}]]])))
|
:enable-empty-sections true}]]])))
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
[status-im.ui.components.contact.contact :as contact]
|
[status-im.ui.components.contact.contact :as contact]
|
||||||
[status-im.ui.components.list.views :as list]
|
[status-im.ui.components.list.views :as list]
|
||||||
[status-im.ui.components.colors :as colors]
|
[status-im.ui.components.colors :as colors]
|
||||||
[status-im.ui.components.styles :as components.styles]
|
|
||||||
[status-im.ui.components.status-bar.view :as status-bar]
|
[status-im.ui.components.status-bar.view :as status-bar]
|
||||||
[status-im.ui.components.toolbar.view :as toolbar]
|
[status-im.ui.components.toolbar.view :as toolbar]
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
status-im.commands.subs
|
status-im.commands.subs
|
||||||
status-im.ui.screens.accounts.subs
|
status-im.ui.screens.accounts.subs
|
||||||
status-im.ui.screens.home.subs
|
status-im.ui.screens.home.subs
|
||||||
status-im.ui.screens.group.chat-settings.subs
|
|
||||||
status-im.ui.screens.contacts.subs
|
status-im.ui.screens.contacts.subs
|
||||||
status-im.ui.screens.group.subs
|
status-im.ui.screens.group.subs
|
||||||
status-im.ui.screens.wallet.subs
|
status-im.ui.screens.wallet.subs
|
||||||
|
|
|
@ -15,16 +15,11 @@
|
||||||
[status-im.ui.screens.add-new.new-chat.views :refer [new-chat]]
|
[status-im.ui.screens.add-new.new-chat.views :refer [new-chat]]
|
||||||
[status-im.ui.screens.add-new.new-public-chat.view :refer [new-public-chat]]
|
[status-im.ui.screens.add-new.new-public-chat.view :refer [new-public-chat]]
|
||||||
|
|
||||||
[status-im.ui.screens.contacts.contact-list-modal.views :refer [contact-list-modal]]
|
|
||||||
|
|
||||||
[status-im.ui.screens.qr-scanner.views :refer [qr-scanner]]
|
[status-im.ui.screens.qr-scanner.views :refer [qr-scanner]]
|
||||||
|
|
||||||
[status-im.ui.screens.group.views :refer [new-group]]
|
[status-im.ui.screens.group.views :refer [new-group]]
|
||||||
[status-im.ui.screens.group.edit-contacts.views :refer [edit-contact-group-contact-list]]
|
|
||||||
[status-im.ui.screens.group.add-contacts.views :refer [contact-toggle-list
|
[status-im.ui.screens.group.add-contacts.views :refer [contact-toggle-list
|
||||||
add-contacts-toggle-list
|
|
||||||
add-participants-toggle-list]]
|
add-participants-toggle-list]]
|
||||||
|
|
||||||
[status-im.ui.screens.profile.user.views :as profile.user]
|
[status-im.ui.screens.profile.user.views :as profile.user]
|
||||||
[status-im.ui.screens.profile.contact.views :as profile.contact]
|
[status-im.ui.screens.profile.contact.views :as profile.contact]
|
||||||
[status-im.ui.screens.profile.group-chat.views :as profile.group-chat]
|
[status-im.ui.screens.profile.group-chat.views :as profile.group-chat]
|
||||||
|
@ -136,9 +131,7 @@
|
||||||
:wallet-request-assets wallet.components/request-assets
|
:wallet-request-assets wallet.components/request-assets
|
||||||
:new add-new
|
:new add-new
|
||||||
:new-group new-group
|
:new-group new-group
|
||||||
:add-contacts-toggle-list add-contacts-toggle-list
|
|
||||||
:add-participants-toggle-list add-participants-toggle-list
|
:add-participants-toggle-list add-participants-toggle-list
|
||||||
:edit-group-contact-list edit-contact-group-contact-list
|
|
||||||
:new-public-chat new-public-chat
|
:new-public-chat new-public-chat
|
||||||
:contact-toggle-list contact-toggle-list
|
:contact-toggle-list contact-toggle-list
|
||||||
:new-chat new-chat
|
:new-chat new-chat
|
||||||
|
@ -165,7 +158,6 @@
|
||||||
(defn get-modal-component [modal-view]
|
(defn get-modal-component [modal-view]
|
||||||
(case modal-view
|
(case modal-view
|
||||||
:qr-scanner qr-scanner
|
:qr-scanner qr-scanner
|
||||||
:contact-list-modal contact-list-modal
|
|
||||||
:wallet-transactions-filter wallet-transactions/filter-history
|
:wallet-transactions-filter wallet-transactions/filter-history
|
||||||
:wallet-settings-assets wallet-settings/manage-assets
|
:wallet-settings-assets wallet-settings/manage-assets
|
||||||
:wallet-send-transaction-modal send-transaction-modal
|
:wallet-send-transaction-modal send-transaction-modal
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
(and (string? url) (s/starts-with? url local-protocol)))
|
(and (string? url) (s/starts-with? url local-protocol)))
|
||||||
|
|
||||||
(def default-contacts (json->clj (slurp "resources/default_contacts.json")))
|
(def default-contacts (json->clj (slurp "resources/default_contacts.json")))
|
||||||
(def default-contact-groups (json->clj (slurp "resources/default_contact_groups.json")))
|
|
||||||
|
|
||||||
(def transactor-js (slurp-bot :transactor))
|
(def transactor-js (slurp-bot :transactor))
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
:trigger [:show-profile]
|
:trigger [:show-profile]
|
||||||
:properties {:target :show-profile}}
|
:properties {:target :show-profile}}
|
||||||
{:label "Tap"
|
{:label "Tap"
|
||||||
:trigger [:open-contact-toggle-list :chat-group]
|
:trigger [:open-contact-toggle-list]
|
||||||
:properties {:target :new-group-chat}}
|
:properties {:target :new-group-chat}}
|
||||||
{:label "Tap"
|
{:label "Tap"
|
||||||
:trigger [:navigate-to :new-public-chat]
|
:trigger [:navigate-to :new-public-chat]
|
||||||
|
|
|
@ -5,11 +5,9 @@
|
||||||
[day8.re-frame.test :refer-macros [run-test-sync]]
|
[day8.re-frame.test :refer-macros [run-test-sync]]
|
||||||
status-im.ui.screens.db
|
status-im.ui.screens.db
|
||||||
[status-im.ui.screens.contacts.events :as contacts-events]
|
[status-im.ui.screens.contacts.events :as contacts-events]
|
||||||
[status-im.ui.screens.group.events :as group-events]
|
|
||||||
status-im.ui.screens.subs
|
status-im.ui.screens.subs
|
||||||
[status-im.ui.screens.events :as events]
|
[status-im.ui.screens.events :as events]
|
||||||
[status-im.utils.js-resources :as js-res]
|
[status-im.utils.js-resources :as js-res]))
|
||||||
[status-im.utils.datetime :as datetime]))
|
|
||||||
|
|
||||||
(def test-contact-group
|
(def test-contact-group
|
||||||
{:group-id "1501682106404-685e041e-38e7-593e-b42c-fb4cabd7faa4"
|
{:group-id "1501682106404-685e041e-38e7-593e-b42c-fb4cabd7faa4"
|
||||||
|
@ -70,12 +68,6 @@
|
||||||
(rf/reg-fx ::contacts-events/stop-watching-contact #())
|
(rf/reg-fx ::contacts-events/stop-watching-contact #())
|
||||||
(rf/reg-fx ::contacts-events/send-contact-request-fx #())
|
(rf/reg-fx ::contacts-events/send-contact-request-fx #())
|
||||||
|
|
||||||
(rf/reg-fx ::group-events/save-contact-group #())
|
|
||||||
(rf/reg-fx ::group-events/save-contact-groups #())
|
|
||||||
(rf/reg-fx ::group-events/add-contacts-to-contact-group #())
|
|
||||||
(rf/reg-fx ::group-events/save-contact-group-property #())
|
|
||||||
(rf/reg-fx ::group-events/add-contacts-to-contact-group #())
|
|
||||||
|
|
||||||
(rf/reg-fx :data-store/save-chat #())
|
(rf/reg-fx :data-store/save-chat #())
|
||||||
|
|
||||||
(rf/reg-cofx
|
(rf/reg-cofx
|
||||||
|
@ -88,18 +80,11 @@
|
||||||
(fn [cofx]
|
(fn [cofx]
|
||||||
(assoc cofx :get-local-storage-data (constantly nil))))
|
(assoc cofx :get-local-storage-data (constantly nil))))
|
||||||
|
|
||||||
(rf/reg-cofx
|
|
||||||
::group-events/get-all-contact-groups
|
|
||||||
(fn [coeffects _]
|
|
||||||
(assoc coeffects :all-groups {(:group-id test-contact-group) test-contact-group})))
|
|
||||||
|
|
||||||
;;TODO implement tests later for :add-chat? and :bot-url
|
;;TODO implement tests later for :add-chat? and :bot-url
|
||||||
(rf/reg-cofx
|
(rf/reg-cofx
|
||||||
::contacts-events/get-default-contacts-and-groups
|
::contacts-events/get-default-contacts-and-groups
|
||||||
(fn [coeffects _]
|
(fn [coeffects _]
|
||||||
(assoc coeffects
|
(assoc coeffects :default-contacts (select-keys js-res/default-contacts [:demo-bot])))))
|
||||||
:default-contacts (select-keys js-res/default-contacts [:demo-bot])
|
|
||||||
:default-groups (select-keys js-res/default-contact-groups [:dapps])))))
|
|
||||||
|
|
||||||
#_(deftest contacts-events
|
#_(deftest contacts-events
|
||||||
"load-contacts
|
"load-contacts
|
||||||
|
|
Loading…
Reference in New Issue