mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 07:29:08 -05:00
Fixed some bugs on history loading on page changes.
This commit is contained in:
parent
4c4978d948
commit
f91203d5e2
2 changed files with 25 additions and 19 deletions
|
@ -58,11 +58,12 @@
|
||||||
(update :shapes-by-id merge shapes-by-id)
|
(update :shapes-by-id merge shapes-by-id)
|
||||||
(update-in [:pages-by-id] assoc (:id page) page))))
|
(update-in [:pages-by-id] assoc (:id page) page))))
|
||||||
|
|
||||||
(defn dissoc-page
|
(defn purge-page
|
||||||
"Remove page and all related stuff from the state."
|
"Remove page and all related stuff from the state."
|
||||||
[state id]
|
[state id]
|
||||||
(-> state
|
(-> state
|
||||||
(update :pages-by-id dissoc id)
|
(update :pages-by-id dissoc id)
|
||||||
|
(update :pagedata-by-id dissoc id)
|
||||||
(dissoc-page-shapes id)))
|
(dissoc-page-shapes id)))
|
||||||
|
|
||||||
(defn project-pages
|
(defn project-pages
|
||||||
|
|
|
@ -36,27 +36,11 @@
|
||||||
;; Component
|
;; Component
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(defn- history-toolbox-will-mount
|
|
||||||
[own]
|
|
||||||
(let [page @wb/page-l]
|
|
||||||
(rs/emit! (dpg/fetch-page-history (:id page))
|
|
||||||
(dpg/fetch-pinned-page-history (:id page)))
|
|
||||||
(add-watch wb/page-l ::key (fn [_ _ ov nv]
|
|
||||||
(when (and (> (:version nv) (:version ov))
|
|
||||||
(not (:history nv)))
|
|
||||||
(rs/emit! (dpg/fetch-page-history (:id nv))))))
|
|
||||||
own))
|
|
||||||
|
|
||||||
(defn- history-toolbox-will-unmount
|
|
||||||
[own]
|
|
||||||
(rs/emit! (dpg/clean-page-history))
|
|
||||||
(remove-watch wb/page-l ::key)
|
|
||||||
own)
|
|
||||||
|
|
||||||
(defn history-list-render
|
(defn history-list-render
|
||||||
[own page history]
|
[own page history]
|
||||||
(let [select #(rs/emit! (dpg/select-page-history (:id page) %))
|
(let [select #(rs/emit! (dpg/select-page-history (:id page) %))
|
||||||
show-more? (> (count (:items history)) 15)]
|
min-version (apply min (map :version (:items history)))
|
||||||
|
show-more? (pos? min-version)]
|
||||||
(html
|
(html
|
||||||
[:ul.history-content
|
[:ul.history-content
|
||||||
[:li {:class (when-not (:selected history) "current")
|
[:li {:class (when-not (:selected history) "current")
|
||||||
|
@ -98,6 +82,27 @@
|
||||||
:name "history-pinned-list"
|
:name "history-pinned-list"
|
||||||
:mixins [mx/static]}))
|
:mixins [mx/static]}))
|
||||||
|
|
||||||
|
|
||||||
|
(defn- history-toolbox-will-mount
|
||||||
|
[own]
|
||||||
|
(let [page @wb/page-l]
|
||||||
|
(rs/emit! (dpg/fetch-page-history (:id page))
|
||||||
|
(dpg/fetch-pinned-page-history (:id page)))
|
||||||
|
(add-watch wb/page-l ::key
|
||||||
|
(fn [_ _ ov nv]
|
||||||
|
(when (or (and (> (:version nv) (:version ov))
|
||||||
|
(not (:history nv)))
|
||||||
|
(not= (:id ov) (:id nv)))
|
||||||
|
(rs/emit! (dpg/fetch-page-history (:id nv))
|
||||||
|
(dpg/fetch-pinned-page-history (:id nv))))))
|
||||||
|
own))
|
||||||
|
|
||||||
|
(defn- history-toolbox-will-unmount
|
||||||
|
[own]
|
||||||
|
(rs/emit! (dpg/clean-page-history))
|
||||||
|
(remove-watch wb/page-l ::key)
|
||||||
|
own)
|
||||||
|
|
||||||
(defn history-toolbox-render
|
(defn history-toolbox-render
|
||||||
[own]
|
[own]
|
||||||
(let [local (:rum/local own)
|
(let [local (:rum/local own)
|
||||||
|
|
Loading…
Add table
Reference in a new issue