mirror of
https://github.com/penpot/penpot.git
synced 2025-05-25 21:56:13 +02:00
Improved history refresh mechanism.
This commit is contained in:
parent
b96a554c44
commit
41aa1eb8f5
4 changed files with 33 additions and 13 deletions
|
@ -89,14 +89,37 @@
|
||||||
(defrecord CleanPageHistory []
|
(defrecord CleanPageHistory []
|
||||||
rs/UpdateEvent
|
rs/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(-apply-update [_ state]
|
||||||
(-> state
|
(println "CleanPageHistory")
|
||||||
(assoc-in [:workspace :history :items] nil)
|
(assoc-in state [:workspace :history] {})))
|
||||||
(assoc-in [:workspace :history :selected] nil))))
|
|
||||||
|
|
||||||
(defn clean-page-history
|
(defn clean-page-history
|
||||||
[]
|
[]
|
||||||
(CleanPageHistory.))
|
(CleanPageHistory.))
|
||||||
|
|
||||||
|
(defn clean-page-history?
|
||||||
|
[v]
|
||||||
|
(instance? CleanPageHistory v))
|
||||||
|
|
||||||
|
;; --- Watch Page Changes
|
||||||
|
|
||||||
|
(defrecord WatchPageChanges []
|
||||||
|
rs/WatchEvent
|
||||||
|
(-apply-watch [_ state s]
|
||||||
|
(println "WatchPageChanges")
|
||||||
|
(let [stoper (->> (rx/filter clean-page-history? s)
|
||||||
|
(rx/take 1))]
|
||||||
|
(->> (rx/filter udp/page-synced? s)
|
||||||
|
(rx/take-until stoper)
|
||||||
|
(rx/map (comp :id :page))
|
||||||
|
(rx/pr-log "watcher:")
|
||||||
|
(rx/mapcat #(rx/of
|
||||||
|
(fetch-page-history %)
|
||||||
|
(fetch-pinned-page-history %)))))))
|
||||||
|
|
||||||
|
(defn watch-page-changes
|
||||||
|
[]
|
||||||
|
(WatchPageChanges.))
|
||||||
|
|
||||||
;; --- Select Page History
|
;; --- Select Page History
|
||||||
|
|
||||||
(defrecord SelectPageHistory [item]
|
(defrecord SelectPageHistory [item]
|
||||||
|
|
|
@ -119,9 +119,6 @@
|
||||||
|
|
||||||
;; --- Update Page
|
;; --- Update Page
|
||||||
|
|
||||||
(declare fetch-page-history)
|
|
||||||
(declare fetch-pinned-page-history)
|
|
||||||
|
|
||||||
(defrecord UpdatePage [id]
|
(defrecord UpdatePage [id]
|
||||||
rs/WatchEvent
|
rs/WatchEvent
|
||||||
(-apply-watch [this state s]
|
(-apply-watch [this state s]
|
||||||
|
@ -129,12 +126,11 @@
|
||||||
(let [page (get-in state [:pages-by-id id])]
|
(let [page (get-in state [:pages-by-id id])]
|
||||||
(if (:history page)
|
(if (:history page)
|
||||||
(rx/empty)
|
(rx/empty)
|
||||||
(rx/merge
|
(rx/of (sync-page id))))))
|
||||||
(rx/of (sync-page id))
|
|
||||||
(->> (rx/filter page-synced? s)
|
(defn update-page?
|
||||||
(rx/take 1)
|
[v]
|
||||||
(rx/mapcat #(rx/of (fetch-page-history id)
|
(instance? UpdatePage v))
|
||||||
(fetch-pinned-page-history id)))))))))
|
|
||||||
|
|
||||||
(defn update-page
|
(defn update-page
|
||||||
[id]
|
[id]
|
||||||
|
|
|
@ -55,7 +55,6 @@
|
||||||
[own]
|
[own]
|
||||||
(let [profile (rum/react profile-l)
|
(let [profile (rum/react profile-l)
|
||||||
local (:rum/local own)]
|
local (:rum/local own)]
|
||||||
(println "user-render" profile)
|
|
||||||
(html
|
(html
|
||||||
[:div.user-zone {:on-mouse-enter #(swap! local assoc :open true)
|
[:div.user-zone {:on-mouse-enter #(swap! local assoc :open true)
|
||||||
:on-mouse-leave #(swap! local assoc :open false)}
|
:on-mouse-leave #(swap! local assoc :open false)}
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
(let [[projectid pageid] (:rum/props own)]
|
(let [[projectid pageid] (:rum/props own)]
|
||||||
(rs/emit! (dw/initialize projectid pageid)
|
(rs/emit! (dw/initialize projectid pageid)
|
||||||
(udp/fetch-pages projectid)
|
(udp/fetch-pages projectid)
|
||||||
|
(udh/watch-page-changes)
|
||||||
(udh/fetch-page-history pageid)
|
(udh/fetch-page-history pageid)
|
||||||
(udh/fetch-pinned-page-history pageid))
|
(udh/fetch-pinned-page-history pageid))
|
||||||
own))
|
own))
|
||||||
|
@ -78,6 +79,7 @@
|
||||||
|
|
||||||
(defn- workspace-will-unmount
|
(defn- workspace-will-unmount
|
||||||
[own]
|
[own]
|
||||||
|
(rs/emit! (udh/clean-page-history))
|
||||||
(let [sub1 (::sub1 own)
|
(let [sub1 (::sub1 own)
|
||||||
sub2 (::sub2 own)]
|
sub2 (::sub2 own)]
|
||||||
(.close sub1)
|
(.close sub1)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue