🐛 Fix export crash when there's no tokens in the project

This commit is contained in:
Andrey Fedorov 2024-12-11 13:18:48 +01:00
parent 2a766a7190
commit 90e0021cec

View file

@ -323,12 +323,12 @@
:timeout 9000}))))) :timeout 9000})))))
(set! (.-value (mf/ref-val input-ref)) ""))) (set! (.-value (mf/ref-val input-ref)) "")))
on-export (fn [] on-export (fn []
(let [tokens-blob (some-> (deref refs/tokens-lib) (let [tokens-json (some-> (deref refs/tokens-lib)
(ctob/encode-dtcg) (ctob/encode-dtcg)
(clj->js) (clj->js)
(js/JSON.stringify nil 2) (js/JSON.stringify nil 2))]
(wapi/create-blob "application/json"))] (->> (wapi/create-blob (or tokens-json "{}") "application/json")
(dom/trigger-download "tokens.json" tokens-blob)))] (dom/trigger-download "tokens.json"))))]
[:div {:class (stl/css :import-export-button-wrapper)} [:div {:class (stl/css :import-export-button-wrapper)}
[:input {:type "file" [:input {:type "file"