mirror of
https://github.com/status-im/status-react.git
synced 2025-01-10 19:16:59 +00:00
rebase
This commit is contained in:
parent
60680f7293
commit
ae632b6acc
35
resources/default_contact_groups.json
Normal file
35
resources/default_contact_groups.json
Normal file
@ -0,0 +1,35 @@
|
||||
{
|
||||
"dapps":
|
||||
{
|
||||
"name":
|
||||
{
|
||||
"en": "ÐApps"
|
||||
},
|
||||
"contacts":
|
||||
[
|
||||
"wallet",
|
||||
"oaken-water-meter",
|
||||
"melonport",
|
||||
"bchat",
|
||||
"Dentacoin",
|
||||
"Augur",
|
||||
"Ethlance",
|
||||
"Commiteth"
|
||||
]
|
||||
},
|
||||
"state-of-dapps":
|
||||
{
|
||||
"name":
|
||||
{
|
||||
"en": "State of the ÐApps"
|
||||
},
|
||||
"contacts":
|
||||
[
|
||||
"flight-delays-suck",
|
||||
"FirstBlood",
|
||||
"auction-house",
|
||||
"gnosis",
|
||||
"mkr-market"
|
||||
]
|
||||
}
|
||||
}
|
@ -10,7 +10,8 @@
|
||||
},
|
||||
"photo-path": "icon_wallet_avatar",
|
||||
"add-chat?": true,
|
||||
"dapp?": true
|
||||
"dapp?": true,
|
||||
"groups": ["dapps"]
|
||||
},
|
||||
|
||||
"0x0428c9d6c1aaaa8369a7c63819684f30e34396dc0907d49afeac85a0a774ccb919b3482097d992e66bcc538e7a0c6acf874c77748f396f53c0a102e10d1a37765b":
|
||||
@ -35,7 +36,8 @@
|
||||
"dapp-url":
|
||||
{
|
||||
"en": "http://auctionhouse.dappbench.com"
|
||||
}
|
||||
},
|
||||
"groups": ["state-of-dapps"]
|
||||
},
|
||||
|
||||
"flight-delays-suck":
|
||||
@ -49,7 +51,8 @@
|
||||
"dapp-url":
|
||||
{
|
||||
"en": "https://fdd.etherisc.com"
|
||||
}
|
||||
},
|
||||
"groups": ["state-of-dapps"]
|
||||
},
|
||||
|
||||
"mkr-market":
|
||||
@ -63,7 +66,8 @@
|
||||
"dapp-url":
|
||||
{
|
||||
"en": "https://mkr.market"
|
||||
}
|
||||
},
|
||||
"groups": ["state-of-dapps"]
|
||||
},
|
||||
|
||||
"FirstBlood":
|
||||
@ -77,7 +81,8 @@
|
||||
"dapp-url":
|
||||
{
|
||||
"en": "https://app.firstblood.io"
|
||||
}
|
||||
},
|
||||
"groups": ["state-of-dapps"]
|
||||
},
|
||||
|
||||
"oaken-water-meter":
|
||||
@ -91,7 +96,8 @@
|
||||
"dapp-url":
|
||||
{
|
||||
"en": "http://waterflowdapp.projectoaken.com"
|
||||
}
|
||||
},
|
||||
"groups": ["dapps"]
|
||||
},
|
||||
|
||||
"gnosis":
|
||||
@ -105,7 +111,8 @@
|
||||
"dapp-url":
|
||||
{
|
||||
"en": "https://beta.gnosis.pm"
|
||||
}
|
||||
},
|
||||
"groups": ["state-of-dapps"]
|
||||
},
|
||||
|
||||
"melonport":
|
||||
@ -119,7 +126,8 @@
|
||||
"dapp-url":
|
||||
{
|
||||
"en": "https://portal.melonport.com/"
|
||||
}
|
||||
},
|
||||
"groups": ["dapps"]
|
||||
},
|
||||
|
||||
"bchat":
|
||||
@ -133,7 +141,8 @@
|
||||
"dapp-url":
|
||||
{
|
||||
"en": "http://swarm-gateways.net/bzz:/go-bchat.eth/"
|
||||
}
|
||||
},
|
||||
"groups": ["dapps"]
|
||||
},
|
||||
|
||||
"Dentacoin":
|
||||
@ -147,7 +156,8 @@
|
||||
"dapp-url":
|
||||
{
|
||||
"en": "http://dentacoin.com/testnet/"
|
||||
}
|
||||
},
|
||||
"groups": ["dapps"]
|
||||
},
|
||||
|
||||
"Augur":
|
||||
@ -161,7 +171,8 @@
|
||||
"dapp-url":
|
||||
{
|
||||
"en": "https://app.augur.net"
|
||||
}
|
||||
},
|
||||
"groups": ["dapps"]
|
||||
},
|
||||
|
||||
"Ethlance":
|
||||
@ -175,7 +186,8 @@
|
||||
"dapp-url":
|
||||
{
|
||||
"en": "https://madvas.github.io/ethlance/resources/public/"
|
||||
}
|
||||
},
|
||||
"groups": ["dapps"]
|
||||
},
|
||||
|
||||
"Commiteth":
|
||||
@ -189,6 +201,8 @@
|
||||
"dapp-url":
|
||||
{
|
||||
"en": "https://commiteth.com"
|
||||
},
|
||||
"groups": ["dapps"]
|
||||
}
|
||||
},
|
||||
|
||||
@ -203,6 +217,8 @@
|
||||
"dapp-url":
|
||||
{
|
||||
"en": "http://test.etherplay.io"
|
||||
},
|
||||
"groups": ["dapps"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -174,6 +174,13 @@
|
||||
(register-handler :get-contacts-identities
|
||||
(u/side-effect! get-identities-by-contacts!))
|
||||
|
||||
(defn add-contacts-to-groups [{:keys [new-contacts]} _]
|
||||
(let [default-contacts js-res/default-contacts]
|
||||
(doseq [{:keys [whisper-identity]} new-contacts]
|
||||
(let [groups (:groups ((keyword whisper-identity) default-contacts))]
|
||||
(doseq [group groups]
|
||||
(dispatch [:add-contacts-to-group group [whisper-identity]]))))))
|
||||
|
||||
(defn save-contacts! [{:keys [new-contacts]} _]
|
||||
(contacts/save-all new-contacts))
|
||||
|
||||
@ -209,8 +216,15 @@
|
||||
(u/side-effect!
|
||||
(fn [{:keys [chats groups]}]
|
||||
(let [default-contacts js-res/default-contacts
|
||||
default-dapps-group-contacts (mapv #(hash-map :identity (clojure.core/name (first %)))
|
||||
(filter #(true? (:dapp? (second %))) default-contacts))]
|
||||
default-groups js-res/default-contact-groups]
|
||||
(dispatch [:add-groups (mapv
|
||||
(fn [[id {:keys [name contacts]}]]
|
||||
{:group-id (clojure.core/name id)
|
||||
:name (:en name)
|
||||
:order 0
|
||||
:timestamp (random/timestamp)
|
||||
:contacts (mapv #(hash-map :identity %) contacts)})
|
||||
default-groups)])
|
||||
(doseq [[id {:keys [name photo-path public-key add-chat?
|
||||
dapp? dapp-url dapp-hash]}] default-contacts]
|
||||
(let [id' (clojure.core/name id)]
|
||||
@ -224,16 +238,12 @@
|
||||
:public-key public-key
|
||||
:dapp? dapp?
|
||||
:dapp-url (:en dapp-url)
|
||||
:dapp-hash dapp-hash}]]))))
|
||||
(dispatch [:add-groups [{:group-id "dapps"
|
||||
:name (label :t/contacts-group-dapps)
|
||||
:order 0
|
||||
:timestamp (random/timestamp)
|
||||
:contacts default-dapps-group-contacts}]])))))
|
||||
:dapp-hash dapp-hash}]]))))))))
|
||||
|
||||
(register-handler :add-contacts
|
||||
(after save-contacts!)
|
||||
add-new-contacts)
|
||||
(-> add-new-contacts
|
||||
((after save-contacts!))
|
||||
((after add-contacts-to-groups))))
|
||||
|
||||
(defn add-new-contact [db [_ {:keys [whisper-identity] :as contact}]]
|
||||
(-> db
|
||||
|
@ -42,7 +42,9 @@
|
||||
(defn- save-contacts
|
||||
[identities contacts]
|
||||
(doseq [contact-identity identities]
|
||||
(.push contacts (clj->js {:identity contact-identity}))))
|
||||
(when-not (.find contacts (fn [object _ _]
|
||||
(= contact-identity (aget object "identity"))))
|
||||
(.push contacts (clj->js {:identity contact-identity})))))
|
||||
|
||||
(defn add-contacts
|
||||
[group-id identities]
|
||||
|
@ -236,10 +236,11 @@
|
||||
(defn add-new-groups
|
||||
[{:keys [contact-groups] :as db} [_ new-groups]]
|
||||
(let [identities (set (keys contact-groups))
|
||||
old-groups-count (count identities)
|
||||
new-groups' (->> new-groups
|
||||
(map #(update-pending-status contact-groups %))
|
||||
(remove #(identities (:group-id %)))
|
||||
(map #(vector (:group-id %) %))
|
||||
(map #(vector (:group-id %2) (assoc %2 :order %1)) (iterate inc old-groups-count))
|
||||
(into {}))]
|
||||
(-> db
|
||||
(update :contact-groups merge new-groups')
|
||||
@ -317,7 +318,7 @@
|
||||
(defn add-selected-contacts-to-group
|
||||
[{:keys [selected-contacts contact-groups contact-group-id] :as db} _]
|
||||
(let [new-identities (mapv #(hash-map :identity %) selected-contacts)]
|
||||
(update-in db [:contact-groups contact-group-id :contacts] concat new-identities)))
|
||||
(update-in db [:contact-groups contact-group-id :contacts] #(into [] (set (concat % new-identities))))))
|
||||
|
||||
(defn add-selected-contacts-to-group!
|
||||
[{:keys [contact-group-id selected-contacts]} _]
|
||||
@ -325,8 +326,25 @@
|
||||
|
||||
(register-handler
|
||||
:add-selected-contacts-to-group
|
||||
(-> add-selected-contacts-to-group
|
||||
((after add-selected-contacts-to-group!))))
|
||||
(after add-selected-contacts-to-group!)
|
||||
add-selected-contacts-to-group)
|
||||
|
||||
(defn add-contacts-to-group
|
||||
[db [_ group-id contacts]]
|
||||
(let [new-identities (mapv #(hash-map :identity %) contacts)]
|
||||
(if (get-in db [:contact-groups group-id])
|
||||
(update-in db [:contact-groups group-id :contacts] #(into [] (set (concat % new-identities))))
|
||||
db)))
|
||||
|
||||
(defn add-contacts-to-group!
|
||||
[db [_ group-id contacts]]
|
||||
(when (get-in db [:contact-groups group-id])
|
||||
(groups/add-contacts group-id contacts)))
|
||||
|
||||
(register-handler
|
||||
:add-contacts-to-group
|
||||
(after add-contacts-to-group!)
|
||||
add-contacts-to-group)
|
||||
|
||||
(defn delete-group []
|
||||
(fn [{:keys [contact-group-id] :as db} _]
|
||||
|
@ -3,6 +3,7 @@
|
||||
(:require [status-im.utils.types :refer [json->clj]]))
|
||||
|
||||
(def default-contacts (json->clj (slurp "resources/default_contacts.json")))
|
||||
(def default-contact-groups (json->clj (slurp "resources/default_contact_groups.json")))
|
||||
|
||||
(def commands-js (slurp "resources/commands.js"))
|
||||
(def console-js (slurp "resources/console.js"))
|
||||
|
Loading…
x
Reference in New Issue
Block a user