diff --git a/frontend/src/app/main/ui/workspace/tokens/token_set.cljs b/frontend/src/app/main/ui/workspace/tokens/token_set.cljs deleted file mode 100644 index 37717e058..000000000 --- a/frontend/src/app/main/ui/workspace/tokens/token_set.cljs +++ /dev/null @@ -1,45 +0,0 @@ -(ns app.main.ui.workspace.tokens.token-set - (:require - [app.common.types.tokens-lib :as ctob] - [app.main.data.helpers :as dsh])) - -(defn get-workspace-tokens-lib - [state] - (-> (dsh/lookup-file-data state) - (get :tokens-lib))) - -;; Themes ---------------------------------------------------------------------- - -(defn get-active-theme-ids - [state] - (-> (dsh/lookup-file-data state) - (get :token-active-themes #{}))) - -(defn get-temp-theme-id - [state] - (-> (dsh/lookup-file-data state) - (get :token-theme-temporary-id))) - -(defn update-theme-id - [state] - (let [active-themes (get-active-theme-ids state) - temporary-theme-id (get-temp-theme-id state)] - (cond - (empty? active-themes) temporary-theme-id - (= 1 (count active-themes)) (first active-themes) - :else temporary-theme-id))) - -(defn get-workspace-token-theme - [id state] - (-> (dsh/lookup-file-data state) - (get :token-themes-index) - (get id))) - -(defn add-token-set-to-token-theme [token-set-id token-theme] - (update token-theme :sets conj token-set-id)) - - ;; Sets ------------------------------------------------------------------------ - -(defn get-active-theme-sets-tokens-names-map [state] - (when-let [lib (get-workspace-tokens-lib state)] - (ctob/get-active-themes-set-tokens lib))) diff --git a/frontend/src/app/main/ui/workspace/tokens/update.cljs b/frontend/src/app/main/ui/workspace/tokens/update.cljs index 9de0bd233..59b3b8bea 100644 --- a/frontend/src/app/main/ui/workspace/tokens/update.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/update.cljs @@ -9,13 +9,13 @@ [app.common.files.helpers :as cfh] [app.common.logging :as l] [app.common.types.token :as ctt] + [app.common.types.tokens-lib :as ctob] [app.main.data.helpers :as dsh] [app.main.data.workspace.shapes :as dwsh] [app.main.data.workspace.thumbnails :as dwt] [app.main.data.workspace.undo :as dwu] [app.main.ui.workspace.tokens.changes :as wtch] [app.main.ui.workspace.tokens.style-dictionary :as wtsd] - [app.main.ui.workspace.tokens.token-set :as wtts] [app.util.time :as dt] [beicon.v2.core :as rx] [clojure.data :as data] @@ -182,12 +182,14 @@ (ptk/reify ::update-workspace-tokens ptk/WatchEvent (watch [_ state _] - (let [tokens (-> (wtts/get-active-theme-sets-tokens-names-map state) - (wtsd/resolve-tokens+))] - (->> (rx/from tokens) - (rx/mapcat (fn [sd-tokens] - (let [undo-id (js/Symbol)] - (rx/concat - (rx/of (dwu/start-undo-transaction undo-id :timeout false)) - (update-tokens state sd-tokens) - (rx/of (dwu/commit-undo-transaction undo-id))))))))))) + (when-let [tokens-lib (-> (dsh/lookup-file-data state) + (get :tokens-lib))] + (let [tokens (-> (ctob/get-active-themes-set-tokens tokens-lib) + (wtsd/resolve-tokens+))] + (->> (rx/from tokens) + (rx/mapcat (fn [sd-tokens] + (let [undo-id (js/Symbol)] + (rx/concat + (rx/of (dwu/start-undo-transaction undo-id :timeout false)) + (update-tokens state sd-tokens) + (rx/of (dwu/commit-undo-transaction undo-id)))))))))))) \ No newline at end of file