[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))))
(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
"Sorts message-references sequence primary by clock value,
breaking ties by `:message-id`"
@ -104,7 +80,6 @@
:chats chats
:contacts/dapps default-dapps)}
(group-messages)
(add-default-contacts)
(commands/load-commands commands/register))))
(fx/defn initialize-pending-messages

View File

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

View File

@ -13,11 +13,6 @@
[status-im.utils.utils :as utils]
[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
[{:keys [db all-contacts]}]
(let [contacts-list (map #(vector (:whisper-identity %) %) all-contacts)

View File

@ -84,7 +84,6 @@
(handlers/register-handler-fx
:init.callback/account-change-success
[(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 :data-store/all-chats)
(re-frame/inject-cofx :data-store/get-messages)

View File

@ -3,7 +3,6 @@
(:require
[cljs.spec.alpha :as spec]
[status-im.react-native.js-dependencies :as rn-dependencies]
[status-im.utils.js-resources :refer [default-contacts]]
[clojure.string :as string]
[clojure.set :as set]
[status-im.utils.types :as types]))
@ -279,12 +278,6 @@
(def locale
(.-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
([value currency-code]
(format-currency value currency-code true))

View File

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

View File

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