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