diff --git a/src/uxbox/state/project.cljs b/src/uxbox/state/project.cljs index 42ee54e32d..fc5cfc8a33 100644 --- a/src/uxbox/state/project.cljs +++ b/src/uxbox/state/project.cljs @@ -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 diff --git a/src/uxbox/ui/workspace/sidebar/history.cljs b/src/uxbox/ui/workspace/sidebar/history.cljs index a3f3729e37..0c6d96746d 100644 --- a/src/uxbox/ui/workspace/sidebar/history.cljs +++ b/src/uxbox/ui/workspace/sidebar/history.cljs @@ -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)