Fixed missing support for external components

This commit is contained in:
Julien Eluard 2018-10-11 13:46:42 +02:00
parent 80f6d2e806
commit aa755e3c23
No known key found for this signature in database
GPG Key ID: 6FD7DB5437FCBEF6
3 changed files with 13 additions and 9 deletions

View File

@ -9,12 +9,13 @@
(defn ^:export from-clj [o]
(clj->js o))
(defn component [])
(def ctx
{:capacities {:components {'text {:value :text} 'view {:value :div} 'token-selector {:value :div} 'asset-selector {:value :div}
'send-status {:value :div} 'nft-token {:value :div}}
{:capacities {:components {'text {:value component} 'view {:value component} 'token-selector {:value component} 'asset-selector {:value component}
'send-status {:value component} 'nft-token {:value component}}
:queries {'get-collectible-token {:value :get-collectible-token}}
:hooks {:commands {:properties {:scope #{:personal-chats :public-chats}
:description :string
:short-preview :view
:preview :view
:parameters [{:id :keyword

View File

@ -105,7 +105,8 @@
[(or component element)])
%)))
(nil? component) (errors/accumulate-errors [(errors/error ::errors/unknown-component element)])
(seq errors) (errors/accumulate-errors errors))))))
(seq errors) (errors/accumulate-errors errors)))
:else {:errors [(errors/error ::errors/unknown-component o)]})))
(defn parse [ctx ext o]
(if (list? o) ;; TODO introduce a block? fn
@ -138,8 +139,10 @@
(defmethod types/resolve :view [ctx ext type value]
(let [{:keys [data errors]} (reference/resolve ctx ext type value)]
(if data
(let [{:keys [data errors] :as m} (parse ctx ext data)]
;; TODO Might fail at runtime if destructuring is incorrect
(errors/merge-errors (when data {:data (fn [o] (hiccup-with-properties data o))})
(concat errors (:errors ext))))
(if (fn? data)
{:data data}
(let [{:keys [data errors] :as m} (parse ctx ext data)]
;; TODO Might fail at runtime if destructuring is incorrect
(errors/merge-errors (when data {:data (fn [o] (hiccup-with-properties data o))})
(concat errors (:errors ext)))))
{:errors errors})))

View File

@ -17,7 +17,7 @@
const ipfs = new window.Ipfs();
async function load() {
const buffer = await loadIPFS(ipfs, "QmQ6FDAMYV728mAQdox3zFuZ4pj4CfaEu1pMe1JA9duJ13");
const buffer = await loadIPFS(ipfs, "QmWDY22VajAr2LMWV8nTUTnvgDXXfmhWnZbW8jUDP2Pth7");
return buffer.toString();
}