[refactor] remove default contacts

transactor and demo-bot are not used anymore and related code can therefore
be deleted
This commit is contained in:
Eric Dvorsak 2018-10-26 18:53:55 +02:00 committed by yenda
parent b7b7806ed1
commit 38ec77b97b
No known key found for this signature in database
GPG Key ID: 0095623C0069DCE6
8 changed files with 5 additions and 70 deletions

View File

@ -1,21 +0,0 @@
{
"transactor":
{
"name":
{
"en": "Transactor"
},
"dapp?": true,
"hide-contact?": true,
"bot-url": "local://transactor-bot"
},
"demo-bot":
{
"name":
{
"en": "Demo bot"
},
"dapp?": true,
"bot-url": "local://demo-bot"
}
}

View File

@ -11,30 +11,6 @@
(def index-messages (partial into {} (map (juxt :message-id identity)))) (def index-messages (partial into {} (map (juxt :message-id identity))))
(fx/defn add-default-contacts
[{:keys [db default-contacts] :as cofx}]
(let [new-contacts (-> {}
(into (map (fn [[id props]]
(let [contact-id (name id)]
[contact-id {:whisper-identity contact-id
:address (utils.contacts/public-key->address contact-id)
:name (-> props :name :en)
:photo-path (:photo-path props)
:public-key (:public-key props)
:unremovable? (-> props :unremovable? boolean)
:hide-contact? (-> props :hide-contact? boolean)
:pending? (-> props :pending? boolean)
:dapp? (:dapp? props)
:dapp-url (-> props :dapp-url :en)
:bot-url (:bot-url props)
:description (:description props)}])))
default-contacts))
existing-contacts (:contacts/contacts db)
contacts-to-add (select-keys new-contacts (set/difference (set (keys new-contacts))
(set (keys existing-contacts))))]
{:db (update db :contacts/contacts merge contacts-to-add)
:data-store/tx [(contacts-store/save-contacts-tx (vals contacts-to-add))]}))
(defn- sort-references (defn- sort-references
"Sorts message-references sequence primary by clock value, "Sorts message-references sequence primary by clock value,
breaking ties by `:message-id`" breaking ties by `:message-id`"
@ -104,7 +80,6 @@
:chats chats :chats chats
:contacts/dapps default-dapps)} :contacts/dapps default-dapps)}
(group-messages) (group-messages)
(add-default-contacts)
(commands/load-commands commands/register)))) (commands/load-commands commands/register))))
(fx/defn initialize-pending-messages (fx/defn initialize-pending-messages

View File

@ -37,11 +37,8 @@
(cond (cond
public? (str "#" name) public? (str "#" name)
group-chat name group-chat name
:else (i18n/get-contact-translated :else (or contact-name
chat-id (gfycat/generate-gfy chat-id))))
:name
(or contact-name
(gfycat/generate-gfy chat-id)))))
(reg-sub (reg-sub
:get-current-chat-name :get-current-chat-name
:<- [:get-current-chat-contact] :<- [:get-current-chat-contact]

View File

@ -13,11 +13,6 @@
[status-im.utils.utils :as utils] [status-im.utils.utils :as utils]
[status-im.utils.fx :as fx])) [status-im.utils.fx :as fx]))
(re-frame/reg-cofx
:get-default-contacts
(fn [coeffects _]
(assoc coeffects :default-contacts js-res/default-contacts)))
(fx/defn load-contacts (fx/defn load-contacts
[{:keys [db all-contacts]}] [{:keys [db all-contacts]}]
(let [contacts-list (map #(vector (:whisper-identity %) %) all-contacts) (let [contacts-list (map #(vector (:whisper-identity %) %) all-contacts)

View File

@ -84,7 +84,6 @@
(handlers/register-handler-fx (handlers/register-handler-fx
:init.callback/account-change-success :init.callback/account-change-success
[(re-frame/inject-cofx :web3/get-web3) [(re-frame/inject-cofx :web3/get-web3)
(re-frame/inject-cofx :get-default-contacts)
(re-frame/inject-cofx :get-default-dapps) (re-frame/inject-cofx :get-default-dapps)
(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)

View File

@ -3,7 +3,6 @@
(:require (:require
[cljs.spec.alpha :as spec] [cljs.spec.alpha :as spec]
[status-im.react-native.js-dependencies :as rn-dependencies] [status-im.react-native.js-dependencies :as rn-dependencies]
[status-im.utils.js-resources :refer [default-contacts]]
[clojure.string :as string] [clojure.string :as string]
[clojure.set :as set] [clojure.set :as set]
[status-im.utils.types :as types])) [status-im.utils.types :as types]))
@ -279,12 +278,6 @@
(def locale (def locale
(.-locale rn-dependencies/i18n)) (.-locale rn-dependencies/i18n))
(defn get-contact-translated [contact-id key fallback]
(let [translation #(get-in default-contacts [(keyword contact-id) key (keyword %)])]
(or (translation locale)
(translation (subs locale 0 2))
fallback)))
(defn format-currency (defn format-currency
([value currency-code] ([value currency-code]
(format-currency value currency-code true)) (format-currency value currency-code true))

View File

@ -29,10 +29,9 @@
:number-of-lines 1} :number-of-lines 1}
(when dapp? {:accessibility-label :dapp-name}) (when dapp? {:accessibility-label :dapp-name})
props) props)
(if (pos? (count name)) (if (string/blank? name)
(i18n/get-contact-translated whisper-identity :name name) (gfycat/generate-gfy whisper-identity)
;;TODO is this correct behaviour? (or name (i18n/label :t/chat-name)))]
(gfycat/generate-gfy whisper-identity))]
(when info (when info
[react/text {:style styles/info-text} [react/text {:style styles/info-text}
info])]])) info])]]))

View File

@ -8,8 +8,6 @@
(defn local-resource? [url] (defn local-resource? [url]
(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 webview-js (slurp "resources/js/webview.js")) (def webview-js (slurp "resources/js/webview.js"))
(def web3 (str "; if (typeof Web3 == 'undefined') {" (def web3 (str "; if (typeof Web3 == 'undefined') {"
(slurp "node_modules/web3/dist/web3.min.js") (slurp "node_modules/web3/dist/web3.min.js")