diff --git a/common/src/app/common/files/changes_builder.cljc b/common/src/app/common/files/changes_builder.cljc index 49eb98ade..ed779cb5c 100644 --- a/common/src/app/common/files/changes_builder.cljc +++ b/common/src/app/common/files/changes_builder.cljc @@ -727,7 +727,7 @@ [changes token-theme-id] (assert-library! changes) (let [library-data (::library-data (meta changes)) - prev-token-theme (get-in library-data [:token-theme token-theme-id])] + prev-token-theme (get-in library-data [:token-themes-index token-theme-id])] (-> changes (update :redo-changes conj {:type :del-token-theme :id token-theme-id}) (update :undo-changes conj {:type :add-token-theme :token-theme prev-token-theme}) diff --git a/common/src/app/common/types/tokens_theme_list.cljc b/common/src/app/common/types/tokens_theme_list.cljc index 4cf43d622..f9c3857ff 100644 --- a/common/src/app/common/types/tokens_theme_list.cljc +++ b/common/src/app/common/types/tokens_theme_list.cljc @@ -48,8 +48,11 @@ (d/update-in-when file-data [:token-themes-index token-theme-id] #(-> (apply f % args) (touch)))) (defn delete-token-theme - [file-data token-id] - file-data) + [file-data theme-id] + (-> file-data + (update :token-themes (fn [ids] (d/removev #(= % theme-id) ids))) + (update :token-themes-index dissoc theme-id) + (update :token-active-themes disj theme-id))) (defn add-token-set [file-data {:keys [index id] :as token-set}] diff --git a/frontend/src/app/main/data/tokens.cljs b/frontend/src/app/main/data/tokens.cljs index 6a2f972bc..db83f9e33 100644 --- a/frontend/src/app/main/data/tokens.cljs +++ b/frontend/src/app/main/data/tokens.cljs @@ -128,6 +128,16 @@ (pcb/update-active-token-themes new-themes themes))] (rx/of (dch/commit-changes changes)))))) +(defn delete-token-theme [token-theme-id] + (ptk/reify ::delete-token-theme + ptk/WatchEvent + (watch [it state _] + (let [data (get state :workspace-data) + changes (-> (pcb/empty-changes it) + (pcb/with-library-data data) + (pcb/delete-token-theme token-theme-id))] + (rx/of (dch/commit-changes changes)))))) + (defn create-token-set [token-set] (let [new-token-set (merge {:id (uuid/next) diff --git a/frontend/src/app/main/ui/workspace/tokens/sidebar.cljs b/frontend/src/app/main/ui/workspace/tokens/sidebar.cljs index 58e2dfda8..1a3f63754 100644 --- a/frontend/src/app/main/ui/workspace/tokens/sidebar.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/sidebar.cljs @@ -214,7 +214,7 @@ [:button {:on-click (fn [e] (dom/prevent-default e) (dom/stop-propagation e) - (st/emit! (wdt/delete-token-set id)))} + (st/emit! (wdt/delete-token-theme id)))} "🗑️"]]]])]])]] [:div.spaced [:b "Sets"]