0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-09 08:20:45 -05:00

Fixed some bugs on history loading on page changes.

This commit is contained in:
Andrey Antukh 2016-03-28 21:55:14 +03:00
parent 4c4978d948
commit f91203d5e2
2 changed files with 25 additions and 19 deletions

View file

@ -58,11 +58,12 @@
(update :shapes-by-id merge shapes-by-id)
(update-in [:pages-by-id] assoc (:id page) page))))
(defn dissoc-page
(defn purge-page
"Remove page and all related stuff from the state."
[state id]
(-> state
(update :pages-by-id dissoc id)
(update :pagedata-by-id dissoc id)
(dissoc-page-shapes id)))
(defn project-pages

View file

@ -36,27 +36,11 @@
;; 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
[own page history]
(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
[:ul.history-content
[:li {:class (when-not (:selected history) "current")
@ -98,6 +82,27 @@
:name "history-pinned-list"
: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
[own]
(let [local (:rum/local own)