0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-04-01 17:41:50 -05:00

🐛 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
### :sparkles: New features
### :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
### :heart: Community contributions by (Thank you!)

View file

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

View file

@ -9,6 +9,7 @@
[app.common.data :as d]
[app.main.data.messages :as dm]
[app.main.data.workspace :as udw]
[app.main.data.workspace.persistence :as dwp]
[app.main.repo :as rp]
[app.main.store :as st]
[app.main.ui.icons :as i]
@ -19,12 +20,22 @@
(defn request-export
[shape exports]
(rp/query! :export
{:page-id (:page-id shape)
:file-id (:file-id shape)
:object-id (:id shape)
:name (:name shape)
:exports exports}))
(let [result-stream
(->> st/stream
(rx/filter dwp/shapes-persited-event?)
(rx/take 1)
(rx/flat-map
#(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
[{:keys [shape page-id file-id] :as props}]