Skip to content

Commit

Permalink
fix persist
Browse files Browse the repository at this point in the history
  • Loading branch information
sprocketc committed Jan 3, 2025
1 parent 36e8712 commit 0e5b482
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 28 deletions.
6 changes: 2 additions & 4 deletions src/renderer/app/effects.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[akiroz.re-frame.storage :as rf.storage]
[config :as config]
[re-frame.core :as rf]
[re-frame.db :as rf.db]
[renderer.app.db :as db]
[renderer.app.events :as-alias e]
[renderer.history.handlers :as history.h]
Expand All @@ -24,9 +23,8 @@

(rf/reg-fx
::persist
(fn []
(let [db @rf.db/app-db
db (cond-> db
(fn [db]
(let [db (cond-> db
(:active-document db)
history.h/drop-rest)]
(->> (select-keys db db/persistent-keys)
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/history/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@
(h/position db)))]
(cond-> context
(and db (not= (h/position db) prev-position))
(rf/assoc-effect :fx (conj (or fx []) [::app.fx/persist])))))))
(rf/assoc-effect :fx (conj (or fx []) [::app.fx/persist db])))))))
14 changes: 7 additions & 7 deletions src/renderer/tool/handlers.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,13 @@
(m/=> wheel-handler [:-> App WheelEvent App])
(defn wheel-handler
[db e]
(-> (if (some (:modifiers e) [:ctrl :alt])
(let [factor (Math/pow (inc (/ (- 1 (:zoom-sensitivity db)) 100))
(- (:delta-y e)))]
(frame.h/zoom-at-pointer db factor))
(frame.h/pan-by db [(:delta-x e) (:delta-y e)]))
(snap.h/update-viewport-tree)
(add-fx [::app.fx/persist])))
(let [db (-> (if (some (:modifiers e) [:ctrl :alt])
(let [factor (Math/pow (inc (/ (- 1 (:zoom-sensitivity db)) 100))
(- (:delta-y e)))]
(frame.h/zoom-at-pointer db factor))
(frame.h/pan-by db [(:delta-x e) (:delta-y e)]))
(snap.h/update-viewport-tree))]
(add-fx db [::app.fx/persist db])))

(m/=> cancel [:-> App App])
(defn cancel
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/tool/impl/base/pan.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@

(defmethod hierarchy/on-drag-end :pan
[db _e]
(-> (h/set-cursor db "grab")
(snap.h/update-viewport-tree)
(h/add-fx [::app.fx/persist])))
(let [db (-> (h/set-cursor db "grab")
(snap.h/update-viewport-tree))]
(h/add-fx db [::app.fx/persist db])))
26 changes: 13 additions & 13 deletions src/renderer/tool/impl/base/zoom.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,21 @@
width-ratio (/ (:width dom-rect) width)
height-ratio (/ (:height dom-rect) height)
current-zoom (get-in db [:documents (:active-document db) :zoom])
zoom (min width-ratio height-ratio)]
(-> (h/dissoc-temp db)
(h/set-cursor (if (pointer/shift? e) "zoom-out" "zoom-in"))
(frame.h/zoom-in-place (if (pointer/shift? e)
(:zoom-sensitivity db)
(/ zoom current-zoom)))
(frame.h/pan-to-bounds [x y offset-x offset-y])
(snap.h/update-viewport-tree)
(h/add-fx [::app.fx/persist]))))
zoom (min width-ratio height-ratio)
db (-> (h/dissoc-temp db)
(h/set-cursor (if (pointer/shift? e) "zoom-out" "zoom-in"))
(frame.h/zoom-in-place (if (pointer/shift? e)
(:zoom-sensitivity db)
(/ zoom current-zoom)))
(frame.h/pan-to-bounds [x y offset-x offset-y])
(snap.h/update-viewport-tree))]
(h/add-fx db [::app.fx/persist db])))

(defmethod hierarchy/on-pointer-up :zoom
[db e]
(let [factor (if (pointer/shift? e)
(:zoom-sensitivity db)
(/ 1 (:zoom-sensitivity db)))]
(-> (frame.h/zoom-at-pointer db factor)
(snap.h/update-viewport-tree)
(h/add-fx [::app.fx/persist]))))
(/ 1 (:zoom-sensitivity db)))
db (-> (frame.h/zoom-at-pointer db factor)
(snap.h/update-viewport-tree))]
(h/add-fx db [::app.fx/persist db])))

0 comments on commit 0e5b482

Please sign in to comment.