Overwrite default contacts with default.json
Also cleanup migration for changed whisper-identities
This commit is contained in:
parent
88d368e970
commit
666ec73959
|
@ -37,5 +37,16 @@
|
|||
local-storage/schema
|
||||
handler-data/schema])
|
||||
|
||||
(defn remove-contact! [new-realm whisper-identity]
|
||||
(when-let [contact (some-> new-realm
|
||||
(.objects "contact")
|
||||
(.filtered (str "whisper-identity = \"" whisper-identity "\""))
|
||||
(aget 0))]
|
||||
(log/debug "v17 Removing contact" (pr-str contact))
|
||||
(.delete new-realm contact)))
|
||||
|
||||
;; NOTE(oskarth): Resets Realm for some dApps to be loaded by default_contacts.json instead.
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating v17 account database: " old-realm new-realm))
|
||||
(log/debug "migrating v17 account database: " old-realm new-realm)
|
||||
(doseq [contact ["oaken-water-meter" "gnosis" "Commiteth" "melonport"]]
|
||||
(remove-contact! new-realm contact)))
|
||||
|
|
|
@ -211,15 +211,12 @@
|
|||
:timestamp (random/timestamp)
|
||||
:contacts (mapv #(hash-map :identity %) contacts)})]])
|
||||
|
||||
;; TODO(oskarth): Consider getting rid of the :when so we can overwrite default
|
||||
;; contacts with default_contacts.json This requires changing semantics of
|
||||
;; update-pending-status (from :add-contacts handler) too.
|
||||
;; NOTE(oskarth): We now overwrite default contacts upon upgrade with default_contacts.json data.
|
||||
(defn- prepare-default-contacts-events [contacts default-contacts]
|
||||
[[:add-contacts
|
||||
(for [[id {:keys [name photo-path public-key add-chat? pending? description
|
||||
dapp? dapp-url dapp-hash bot-url unremovable? mixable?]}] default-contacts
|
||||
:let [id' (clojure.core/name id)]
|
||||
:when (not (get contacts id'))]
|
||||
:let [id' (clojure.core/name id)]]
|
||||
{:whisper-identity id'
|
||||
:address (public-key->address id')
|
||||
:name (:en name)
|
||||
|
@ -283,10 +280,10 @@
|
|||
:add-contacts
|
||||
(fn [{:keys [db]} [_ new-contacts]]
|
||||
(let [{:contacts/keys [contacts]} db
|
||||
identities (set (keys contacts))
|
||||
new-contacts' (->> new-contacts
|
||||
(map #(update-pending-status contacts %))
|
||||
(remove #(identities (:whisper-identity %)))
|
||||
;; NOTE(oskarth): Overwriting default contacts here
|
||||
;;(remove #(identities (:whisper-identity %)))
|
||||
(map #(vector (:whisper-identity %) %))
|
||||
(into {}))]
|
||||
{:db (update db :contacts/contacts merge new-contacts')
|
||||
|
|
Loading…
Reference in New Issue