Skip to content

Commit

Permalink
fix and simplify history drop-rest
Browse files Browse the repository at this point in the history
  • Loading branch information
sprocketc committed Jan 3, 2025
1 parent 2df32ce commit 511dac5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/renderer/history/handlers.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,14 @@
([db]
(reduce drop-rest db (:document-tabs db)))
([db document-id]
(let [pos (get-in db [:documents document-id :history :position])
states-path [:documents document-id :history :states]]
(let [pos (get-in db [:documents document-id :history :position])]
(cond-> db
pos
(-> (update-in states-path select-keys [pos])
(assoc-in (conj states-path pos :index) 0)
(update-in (conj states-path pos) dissoc :parent))))))
(update-in [:documents document-id :history :states]
#(-> (select-keys % [pos])
(assoc-in [pos :index] 0)
(assoc-in [pos :children] [])
(update pos dissoc :parent)))))))

(m/=> preview [:-> App uuid? App])
(defn preview
Expand Down

0 comments on commit 511dac5

Please sign in to comment.