Merge pull request #4802 from penpot/jordisala1991-feature/no-direct-download

 Return blob when exporting using the lib-penpot
This commit is contained in:
Andrey Antukh 2024-06-27 07:59:38 +02:00 committed by GitHub
commit 0239139b4b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -12,13 +12,13 @@
[app.common.media :as cm] [app.common.media :as cm]
[app.common.types.components-list :as ctkl] [app.common.types.components-list :as ctkl]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.util.dom :as dom]
[app.util.json :as json] [app.util.json :as json]
[app.util.webapi :as wapi] [app.util.webapi :as wapi]
[app.util.zip :as uz] [app.util.zip :as uz]
[app.worker.export :as e] [app.worker.export :as e]
[beicon.v2.core :as rx] [beicon.v2.core :as rx]
[cuerdas.core :as str])) [cuerdas.core :as str]
[promesa.core :as p]))
(defn parse-data [data] (defn parse-data [data]
(as-> data $ (as-> data $
@ -262,12 +262,16 @@
(uuid/next)) (uuid/next))
(export [_] (export [_]
(->> (export-file file) (p/create
(rx/subs! (fn [resolve reject]
(fn [value] (->> (export-file file)
(when (not (contains? value :type)) (rx/take 1)
(let [[file export-blob] value] (rx/subs!
(dom/trigger-download (:name file) export-blob)))))))) (fn [value]
(when (not (contains? value :type))
(let [[_ export-blob] value]
(resolve export-blob))))
reject))))))
(defn create-file-export [^string name] (defn create-file-export [^string name]
(binding [cfeat/*current* cfeat/default-features] (binding [cfeat/*current* cfeat/default-features]