🐛 Fix problem with exporting before the document is saved

This commit is contained in:
alonso.torres 2021-10-27 16:05:05 +02:00
parent 756e654d32
commit 0e76aa0265
3 changed files with 23 additions and 6 deletions

View file

@ -6,6 +6,9 @@
### :boom: Breaking changes ### :boom: Breaking changes
### :sparkles: New features ### :sparkles: New features
### :bug: Bugs fixed ### :bug: Bugs fixed
- Fix problem with exporting before the document is saved [Taiga #2189](https://tree.taiga.io/project/penpot/issue/2189)
### :arrow_up: Deps updates ### :arrow_up: Deps updates
### :heart: Community contributions by (Thank you!) ### :heart: Community contributions by (Thank you!)

View file

@ -201,6 +201,9 @@
(s/def ::shapes-changes-persisted (s/def ::shapes-changes-persisted
(s/keys :req-un [::revn ::cp/changes])) (s/keys :req-un [::revn ::cp/changes]))
(defn shapes-persited-event? [event]
(= (ptk/type event) ::changes-persisted))
(defn shapes-changes-persisted (defn shapes-changes-persisted
[file-id {:keys [revn changes] :as params}] [file-id {:keys [revn changes] :as params}]
(us/verify ::us/uuid file-id) (us/verify ::us/uuid file-id)

View file

@ -9,6 +9,7 @@
[app.common.data :as d] [app.common.data :as d]
[app.main.data.messages :as dm] [app.main.data.messages :as dm]
[app.main.data.workspace :as udw] [app.main.data.workspace :as udw]
[app.main.data.workspace.persistence :as dwp]
[app.main.repo :as rp] [app.main.repo :as rp]
[app.main.store :as st] [app.main.store :as st]
[app.main.ui.icons :as i] [app.main.ui.icons :as i]
@ -19,12 +20,22 @@
(defn request-export (defn request-export
[shape exports] [shape exports]
(rp/query! :export (let [result-stream
{:page-id (:page-id shape) (->> st/stream
:file-id (:file-id shape) (rx/filter dwp/shapes-persited-event?)
:object-id (:id shape) (rx/take 1)
:name (:name shape) (rx/flat-map
:exports exports})) #(rp/query!
:export
{:page-id (:page-id shape)
:file-id (:file-id shape)
:object-id (:id shape)
:name (:name shape)
:exports exports})))]
;; Force a persist before exporting otherwise the exported shape could be outdated
(st/emit! ::dwp/force-persist)
result-stream))
(mf/defc exports-menu (mf/defc exports-menu
[{:keys [shape page-id file-id] :as props}] [{:keys [shape page-id file-id] :as props}]