mirror of
https://github.com/penpot/penpot.git
synced 2025-03-12 15:51:37 -05:00
Launch page persistence event before redirect to the view app.
This commit is contained in:
parent
eb19d5f90a
commit
027b4a5d57
2 changed files with 17 additions and 8 deletions
|
@ -15,6 +15,7 @@
|
|||
[uxbox.main.lenses :as ul]
|
||||
[uxbox.util.spec :as us]
|
||||
[uxbox.util.router :as r]
|
||||
[uxbox.util.timers :as ts]
|
||||
[uxbox.util.time :as dt]))
|
||||
|
||||
;; --- Specs
|
||||
|
@ -281,7 +282,7 @@
|
|||
|
||||
;; --- Persist Page
|
||||
|
||||
(deftype PersistPage [id]
|
||||
(deftype PersistPage [id on-success]
|
||||
ptk/WatchEvent
|
||||
(watch [this state s]
|
||||
(let [page (get-in state [:pages id])]
|
||||
|
@ -290,6 +291,8 @@
|
|||
(let [page (pack-page state id)]
|
||||
(->> (rp/req :update/page page)
|
||||
(rx/map :payload)
|
||||
(rx/do #(when (fn? on-success)
|
||||
(ts/schedule 0 on-success)))
|
||||
(rx/map page-persisted)))))))
|
||||
|
||||
(defn persist-page?
|
||||
|
@ -297,15 +300,18 @@
|
|||
(instance? PersistPage v))
|
||||
|
||||
(defn persist-page
|
||||
[id]
|
||||
(PersistPage. id))
|
||||
([id]
|
||||
{:pre [(uuid? id)]}
|
||||
(PersistPage. id (constantly nil)))
|
||||
([id on-success]
|
||||
{:pre [(uuid? id)]}
|
||||
(PersistPage. id on-success)))
|
||||
|
||||
;; --- Page Metadata Persisted
|
||||
|
||||
(deftype MetadataPersisted [id data]
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
;; TODO: page-data update
|
||||
(assoc-in state [:pages id :version] (:version data))))
|
||||
|
||||
(s/def ::metadata-persisted-event
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
[uxbox.main.store :as st]
|
||||
[uxbox.main.refs :as refs]
|
||||
[uxbox.main.data.workspace :as dw]
|
||||
[uxbox.main.data.pages :as udp]
|
||||
[uxbox.main.data.history :as udh]
|
||||
[uxbox.main.data.undo :as udu]
|
||||
[uxbox.main.data.lightbox :as udl]
|
||||
|
@ -20,9 +21,10 @@
|
|||
[uxbox.main.ui.users :as ui.u]
|
||||
[uxbox.main.ui.navigation :as nav]
|
||||
[uxbox.util.router :as r]
|
||||
[uxbox.util.mixins :as mx :include-macros true]
|
||||
[uxbox.util.data :refer [index-of]]
|
||||
[uxbox.util.geom.point :as gpt]
|
||||
[uxbox.util.math :as mth]))
|
||||
[uxbox.util.math :as mth]
|
||||
[uxbox.util.mixins :as mx :include-macros true]))
|
||||
|
||||
;; --- Zoom Widget
|
||||
|
||||
|
@ -43,10 +45,11 @@
|
|||
(defn on-view-clicked
|
||||
[event project page]
|
||||
(let [token (:share-token project)
|
||||
index (:index page)
|
||||
pages (deref refs/selected-project-pages)
|
||||
index (index-of pages page)
|
||||
rval (rand-int 1000000)
|
||||
url (str cfg/viewurl "?v=" rval "#/" token "/" index)]
|
||||
(js/open url "new tab" "")))
|
||||
(st/emit! (udp/persist-page (:id page) #(js/open url "new tab" "")))))
|
||||
|
||||
(mx/defc header
|
||||
{:mixins [mx/static mx/reactive]}
|
||||
|
|
Loading…
Add table
Reference in a new issue