Add token set deletion

This commit is contained in:
Florian Schroedl
2024-08-16 08:04:41 +02:00
parent ae39586d8c
commit 9329513949
4 changed files with 28 additions and 5 deletions

View File

@@ -737,7 +737,7 @@
[changes token-set-id]
(assert-library! changes)
(let [library-data (::library-data (meta changes))
prev-token-set (get-in library-data [:token-set token-set-id])]
prev-token-set (get-in library-data [:token-sets-index token-set-id])]
(-> changes
(update :redo-changes conj {:type :del-token-set :id token-set-id})
(update :undo-changes conj {:type :add-token-set :token-set prev-token-set})

View File

@@ -51,5 +51,8 @@
(d/update-in-when file-data [:token-sets-index token-set-id] #(-> (apply f % args) (touch))))
(defn delete-token-set
[file-data token-id]
file-data)
[file-data token-set-id]
(-> file-data
(update :token-set-groups (fn [xs] (into [] (remove #(= (:id %) token-set-id) xs))))
(update :token-sets-index dissoc token-set-id)
(update :token-themes-index (fn [xs] (update-vals xs #(update % :sets disj token-set-id))))))