mirror of
https://github.com/penpot/penpot.git
synced 2025-02-08 08:09:14 -05:00
🐛 Fix problem with path editor undoing changes
This commit is contained in:
parent
72e29e58d2
commit
a84b23168d
5 changed files with 33 additions and 28 deletions
|
@ -25,6 +25,7 @@
|
|||
|
||||
- Fix pixelated thumbnails [Github #3681](https://github.com/penpot/penpot/issues/3681) [Github #3661](https://github.com/penpot/penpot/issues/3661)
|
||||
- Fix problem with not applying colors to boards [Github #3941](https://github.com/penpot/penpot/issues/3941)
|
||||
- Fix problem with path editor undoing changes [Github #3998](https://github.com/penpot/penpot/issues/3998)
|
||||
|
||||
### :arrow_up: Deps updates
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
(ns app.main.data.workspace.path.common
|
||||
(:require
|
||||
[app.common.schema :as sm]
|
||||
[app.common.svg.path.subpath :as ups]
|
||||
[app.main.data.workspace.path.state :as st]
|
||||
[potok.v2.core :as ptk]))
|
||||
|
||||
|
@ -52,10 +53,11 @@
|
|||
(dissoc state :last-point :prev-handler :drag-handler :preview))
|
||||
|
||||
(defn finish-path
|
||||
[_source]
|
||||
[]
|
||||
(ptk/reify ::finish-path
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [id (st/get-path-id state)]
|
||||
(-> state
|
||||
(update-in [:workspace-local :edit-path id] clean-edit-state))))))
|
||||
(update-in [:workspace-local :edit-path id] clean-edit-state)
|
||||
(update-in (st/get-path-location state :content) ups/close-subpaths))))))
|
||||
|
|
|
@ -153,7 +153,7 @@
|
|||
drag-events-stream
|
||||
(rx/of (finish-drag))
|
||||
(rx/of (close-path-drag-end))))
|
||||
(rx/of (common/finish-path "close-path")))))))
|
||||
(rx/of (common/finish-path)))))))
|
||||
|
||||
(defn close-path-drag-end []
|
||||
(ptk/reify ::close-path-drag-end
|
||||
|
@ -253,7 +253,7 @@
|
|||
(rx/of (common/init-path))
|
||||
(rx/merge mousemove-events
|
||||
mousedown-events)
|
||||
(rx/of (common/finish-path "after-events")))))))
|
||||
(rx/of (common/finish-path)))))))
|
||||
|
||||
(defn setup-frame []
|
||||
(ptk/reify ::setup-frame
|
||||
|
@ -362,7 +362,7 @@
|
|||
(not= content old-content) (rx/of (changes/save-path-content)
|
||||
(start-draw-mode))
|
||||
(= mode :draw) (rx/of :interrupt)
|
||||
:else (rx/of (common/finish-path "changed-content")))))))
|
||||
:else (rx/of (common/finish-path)))))))
|
||||
|
||||
(defn change-edit-mode [mode]
|
||||
(ptk/reify ::change-edit-mode
|
||||
|
@ -376,7 +376,7 @@
|
|||
(watch [_ state _]
|
||||
(let [id (st/get-path-id state)]
|
||||
(cond
|
||||
(and id (= :move mode)) (rx/of (common/finish-path "change-edit-mode"))
|
||||
(and id (= :move mode)) (rx/of (common/finish-path))
|
||||
(and id (= :draw mode)) (rx/of (dwc/hide-toolbar)
|
||||
(start-draw-mode))
|
||||
:else (rx/empty))))))
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
[app.common.geom.shapes :as gsh]
|
||||
[app.common.math :as mth]
|
||||
[app.common.svg.path.command :as upc]
|
||||
[app.common.svg.path.subpath :as ups]
|
||||
[app.main.data.workspace.path.common :as common]
|
||||
[app.util.mouse :as mse]
|
||||
[potok.v2.core :as ptk]))
|
||||
|
@ -117,7 +116,6 @@
|
|||
(let [command (next-node shape position prev-point prev-handler)]
|
||||
(-> shape
|
||||
(update :content (fnil conj []) command)
|
||||
(update :content ups/close-subpaths)
|
||||
(update-selrect))))
|
||||
|
||||
(defn angle-points [common p1 p2]
|
||||
|
|
|
@ -234,7 +234,7 @@
|
|||
(= (ptk/type event) ::changes-persisted))
|
||||
|
||||
(defn shapes-changes-persisted
|
||||
[file-id {:keys [revn changes]}]
|
||||
[file-id {:keys [revn changes] persisted-session-id :session-id}]
|
||||
(dm/assert! (uuid? file-id))
|
||||
(dm/assert! (int? revn))
|
||||
(dm/assert! (cpc/check-changes! changes))
|
||||
|
@ -245,24 +245,28 @@
|
|||
;; NOTE: we don't set the file features context here because
|
||||
;; there are no useful context for code that need to be executed
|
||||
;; on the frontend side
|
||||
|
||||
(if-let [current-file-id (:current-file-id state)]
|
||||
(if (= file-id current-file-id)
|
||||
(let [changes (group-by :page-id changes)]
|
||||
(let [current-file-id (:current-file-id state)
|
||||
current-session-id (:session-id state)]
|
||||
(if (and (some? current-file-id)
|
||||
;; If the remote change is from teh current session we skip
|
||||
(not= persisted-session-id current-session-id))
|
||||
(if (= file-id current-file-id)
|
||||
(let [changes (group-by :page-id changes)]
|
||||
(-> state
|
||||
(update-in [:workspace-file :revn] max revn)
|
||||
(update :workspace-data
|
||||
(fn [file]
|
||||
(loop [fdata file
|
||||
entries (seq changes)]
|
||||
(if-let [[page-id changes] (first entries)]
|
||||
(recur (-> fdata
|
||||
(cpc/process-changes changes)
|
||||
(cond-> (some? page-id)
|
||||
(ctst/update-object-indices page-id)))
|
||||
(rest entries))
|
||||
fdata))))))
|
||||
(-> state
|
||||
(update-in [:workspace-file :revn] max revn)
|
||||
(update :workspace-data (fn [file]
|
||||
(loop [fdata file
|
||||
entries (seq changes)]
|
||||
(if-let [[page-id changes] (first entries)]
|
||||
(recur (-> fdata
|
||||
(cpc/process-changes changes)
|
||||
(cond-> (some? page-id)
|
||||
(ctst/update-object-indices page-id)))
|
||||
(rest entries))
|
||||
fdata))))))
|
||||
(-> state
|
||||
(update-in [:workspace-libraries file-id :revn] max revn)
|
||||
(update-in [:workspace-libraries file-id :data] cpc/process-changes changes)))
|
||||
(update-in [:workspace-libraries file-id :revn] max revn)
|
||||
(update-in [:workspace-libraries file-id :data] cpc/process-changes changes)))
|
||||
|
||||
state))))
|
||||
state)))))
|
||||
|
|
Loading…
Add table
Reference in a new issue