mirror of
https://github.com/penpot/penpot.git
synced 2025-02-05 05:49:07 -05:00
🐛 Prevent ghost state on change from one file to other.
This commit is contained in:
parent
5fb0c5c312
commit
1d678acdd9
2 changed files with 19 additions and 41 deletions
|
@ -368,7 +368,9 @@
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(let [local (:workspace-local state)]
|
(let [local (:workspace-local state)]
|
||||||
(assoc-in state [:workspace-cache page-id] local)))))
|
(-> state
|
||||||
|
(assoc-in [:workspace-cache page-id] local)
|
||||||
|
(update :workspace-data dissoc page-id))))))
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
|
@ -32,30 +32,14 @@
|
||||||
[uxbox.main.ui.workspace.left-toolbar :refer [left-toolbar]]
|
[uxbox.main.ui.workspace.left-toolbar :refer [left-toolbar]]
|
||||||
[uxbox.util.data :refer [classnames]]
|
[uxbox.util.data :refer [classnames]]
|
||||||
[uxbox.util.dom :as dom]
|
[uxbox.util.dom :as dom]
|
||||||
[uxbox.util.geom.point :as gpt]
|
[uxbox.util.geom.point :as gpt]))
|
||||||
[uxbox.util.rdnd :as rdnd]))
|
|
||||||
|
|
||||||
;; --- Workspace
|
;; --- Workspace
|
||||||
|
|
||||||
;; (defn- on-scroll
|
|
||||||
;; [event]
|
|
||||||
;; (let [target (.-target event)
|
|
||||||
;; top (.-scrollTop target)
|
|
||||||
;; left (.-scrollLeft target)]
|
|
||||||
;; (st/emit! (ms/->ScrollEvent (gpt/point left top)))))
|
|
||||||
|
|
||||||
;; (defn- on-wheel
|
|
||||||
;; [event frame]
|
|
||||||
;; (when (kbd/ctrl? event)
|
|
||||||
;; (let [dom (mf/ref-val frame)
|
|
||||||
;; scroll-position (scroll/get-current-position-absolute dom)
|
|
||||||
;; mouse-point @ms/mouse-position]
|
|
||||||
;; (scroll/scroll-to-point dom mouse-point scroll-position))))
|
|
||||||
|
|
||||||
(mf/defc workspace-content
|
(mf/defc workspace-content
|
||||||
[{:keys [page file layout] :as params}]
|
[{:keys [page file layout] :as params}]
|
||||||
(let [frame (mf/use-ref nil)
|
(let [left-sidebar? (not (empty? (keep layout [:layers :sitemap
|
||||||
left-sidebar? (not (empty? (keep layout [:layers :sitemap :document-history :libraries])))
|
:document-history :libraries])))
|
||||||
right-sidebar? (not (empty? (keep layout [:icons :drawtools :element-options])))
|
right-sidebar? (not (empty? (keep layout [:icons :drawtools :element-options])))
|
||||||
classes (classnames
|
classes (classnames
|
||||||
:no-tool-bar-right (not right-sidebar?)
|
:no-tool-bar-right (not right-sidebar?)
|
||||||
|
@ -67,12 +51,7 @@
|
||||||
[:& messages]
|
[:& messages]
|
||||||
[:& context-menu]
|
[:& context-menu]
|
||||||
|
|
||||||
[:section.workspace-content
|
[:section.workspace-content {:class classes}
|
||||||
{:class classes
|
|
||||||
;; :on-scroll on-scroll
|
|
||||||
;; :on-wheel #(on-wheel % frame)
|
|
||||||
}
|
|
||||||
|
|
||||||
[:& history-dialog]
|
[:& history-dialog]
|
||||||
|
|
||||||
;; Rules
|
;; Rules
|
||||||
|
@ -81,12 +60,10 @@
|
||||||
[:& horizontal-rule]
|
[:& horizontal-rule]
|
||||||
[:& vertical-rule]])
|
[:& vertical-rule]])
|
||||||
|
|
||||||
[:section.workspace-viewport {:id "workspace-viewport"
|
[:section.workspace-viewport {:id "workspace-viewport"}
|
||||||
:ref frame}
|
|
||||||
[:& viewport {:page page :file file}]]]
|
[:& viewport {:page page :file file}]]]
|
||||||
|
|
||||||
[:& left-toolbar {:page page
|
[:& left-toolbar {:page page :layout layout}]
|
||||||
:layout layout}]
|
|
||||||
|
|
||||||
;; Aside
|
;; Aside
|
||||||
(when left-sidebar?
|
(when left-sidebar?
|
||||||
|
@ -94,21 +71,20 @@
|
||||||
(when right-sidebar?
|
(when right-sidebar?
|
||||||
[:& right-sidebar {:page page :layout layout}])]))
|
[:& right-sidebar {:page page :layout layout}])]))
|
||||||
|
|
||||||
|
|
||||||
(mf/defc workspace
|
(mf/defc workspace
|
||||||
[{:keys [project-id file-id page-id] :as props}]
|
[{:keys [project-id file-id page-id] :as props}]
|
||||||
|
|
||||||
(-> (mf/deps file-id page-id)
|
(mf/use-effect
|
||||||
(mf/use-effect
|
(mf/deps file-id page-id)
|
||||||
(fn []
|
(fn []
|
||||||
(st/emit! (dw/initialize project-id file-id page-id))
|
(st/emit! (dw/initialize project-id file-id page-id))
|
||||||
#(st/emit! (dw/finalize project-id file-id page-id)))))
|
#(st/emit! (dw/finalize project-id file-id page-id))))
|
||||||
|
|
||||||
(-> (mf/deps file-id)
|
(mf/use-effect
|
||||||
(mf/use-effect
|
(mf/deps file-id)
|
||||||
(fn []
|
(fn []
|
||||||
(st/emit! (dw/initialize-ws file-id))
|
(st/emit! (dw/initialize-ws file-id))
|
||||||
#(st/emit! (dw/finalize-ws file-id)))))
|
#(st/emit! (dw/finalize-ws file-id))))
|
||||||
|
|
||||||
(hooks/use-shortcuts dw/shortcuts)
|
(hooks/use-shortcuts dw/shortcuts)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue