🐛 Fix incorrect handling of selected token set

This commit is contained in:
Andrey Antukh 2025-02-11 12:26:46 +01:00
parent b0a6e5c946
commit a029ec18a6
2 changed files with 32 additions and 25 deletions

View file

@ -31,6 +31,8 @@
;; TOKENS Getters ;; TOKENS Getters
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; FIXME: lookup rename
(defn get-tokens-lib (defn get-tokens-lib
[state] [state]
(-> (dsh/lookup-file-data state) (-> (dsh/lookup-file-data state)
@ -238,12 +240,17 @@
ptk/WatchEvent ptk/WatchEvent
(watch [it state _] (watch [it state _]
(let [data (dsh/lookup-file-data state) (let [data (dsh/lookup-file-data state)
token-set (dwts/get-selected-token-set state) selected (dm/get-in state [:workspace-tokens :selected-token-set-name])
tokens-lib (get-tokens-lib state)
token-set (if selected
(some-> tokens-lib (ctob/get-set selected))
(some-> tokens-lib (ctob/get-sets) (first)))
set-name (or (:name token-set) "Global") set-name (or (:name token-set) "Global")
changes (if (not token-set) changes (if (not token-set)
;; No set created add a global set ;; No set created add a global set
(let [tokens-lib (get-tokens-lib state) (let [token-set (ctob/make-token-set :name set-name :tokens {(:name token) token})
token-set (ctob/make-token-set :name set-name :tokens {(:name token) token})
hidden-theme (ctob/make-hidden-token-theme :sets [set-name]) hidden-theme (ctob/make-hidden-token-theme :sets [set-name])
active-theme-paths (some-> tokens-lib ctob/get-active-theme-paths) active-theme-paths (some-> tokens-lib ctob/get-active-theme-paths)
add-to-hidden-theme? (= active-theme-paths #{ctob/hidden-token-theme-path}) add-to-hidden-theme? (= active-theme-paths #{ctob/hidden-token-theme-path})

View file

@ -12,7 +12,7 @@
[app.main.data.helpers :as dsh])) [app.main.data.helpers :as dsh]))
(defn get-selected-token-set-name [state] (defn get-selected-token-set-name [state]
(or (get-in state [:workspace-local :selected-token-set-name]) (or (get-in state [:workspace-tokens :selected-token-set-name])
(some-> (dsh/lookup-file-data state) (some-> (dsh/lookup-file-data state)
(get :tokens-lib) (get :tokens-lib)
(ctob/get-sets) (ctob/get-sets)