From c9414824a59e85ea51563d2d73b2b476aa6714d0 Mon Sep 17 00:00:00 2001 From: Florian Schroedl Date: Thu, 28 Nov 2024 09:46:21 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=20Remove=20unused=20token=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/src/app/common/types/tokens_list.cljc | 49 ------------ .../app/common/types/tokens_theme_list.cljc | 79 ------------------- 2 files changed, 128 deletions(-) delete mode 100644 common/src/app/common/types/tokens_list.cljc delete mode 100644 common/src/app/common/types/tokens_theme_list.cljc diff --git a/common/src/app/common/types/tokens_list.cljc b/common/src/app/common/types/tokens_list.cljc deleted file mode 100644 index b31262d4d..000000000 --- a/common/src/app/common/types/tokens_list.cljc +++ /dev/null @@ -1,49 +0,0 @@ -;; This Source Code Form is subject to the terms of the Mozilla Public -;; License, v. 2.0. If a copy of the MPL was not distributed with this -;; file, You can obtain one at http://mozilla.org/MPL/2.0/. -;; -;; Copyright (c) KALEIDOS INC - -(ns app.common.types.tokens-list - (:require - [app.common.data :as d] - [app.common.time :as dt])) - -(defn tokens-seq - "Returns a sequence of all tokens within the file data." - [file-data] - (vals (:tokens file-data))) - -(defn- touch - "Updates the `modified-at` timestamp of a token." - [token] - (assoc token :modified-at (dt/now))) - -(defn add-token - "Adds a new token to the file data, setting its `modified-at` timestamp." - [file-data token-set-id token] - (-> file-data - (update :tokens assoc (:id token) (touch token)) - (d/update-in-when [:token-sets-index token-set-id] #(-> - (update % :tokens conj (:id token)) - (touch))))) - -(defn get-token - "Retrieves a token by its ID from the file data." - [file-data token-id] - (get-in file-data [:tokens token-id])) - -(defn set-token - "Sets or updates a token in the file data, updating its `modified-at` timestamp." - [file-data token] - (d/assoc-in-when file-data [:tokens (:id token)] (touch token))) - -(defn update-token - "Applies a function to update a token in the file data, then touches it." - [file-data token-id f & args] - (d/update-in-when file-data [:tokens token-id] #(-> (apply f % args) (touch)))) - -(defn delete-token - "Removes a token from the file data by its ID." - [file-data token-id] - (update file-data :tokens dissoc token-id)) diff --git a/common/src/app/common/types/tokens_theme_list.cljc b/common/src/app/common/types/tokens_theme_list.cljc deleted file mode 100644 index 971c96946..000000000 --- a/common/src/app/common/types/tokens_theme_list.cljc +++ /dev/null @@ -1,79 +0,0 @@ -;; This Source Code Form is subject to the terms of the Mozilla Public -;; License, v. 2.0. If a copy of the MPL was not distributed with this -;; file, You can obtain one at http://mozilla.org/MPL/2.0/. -;; -;; Copyright (c) KALEIDOS INC - -(ns app.common.types.tokens-theme-list - (:require - [app.common.data :as d] - [app.common.time :as dt])) - -(defn- touch - "Updates the `modified-at` timestamp of a token set." - [token-set] - (assoc token-set :modified-at (dt/now))) - -(defn assoc-active-token-themes - [file-data theme-ids] - (assoc file-data :token-active-themes theme-ids)) - -(defn add-temporary-token-theme - [file-data {:keys [id name] :as token-theme}] - (-> file-data - (d/dissoc-in [:token-themes-index (:token-theme-temporary-id file-data)]) - (assoc :token-theme-temporary-id id) - (assoc :token-theme-temporary-name name) - (update :token-themes-index assoc id token-theme))) - -(defn delete-temporary-token-theme - [file-data token-theme-id] - (cond-> file-data - (= (:token-theme-temporary-id file-data) token-theme-id) (dissoc :token-theme-temporary-id :token-theme-temporary-name) - :always (d/dissoc-in [:token-themes-index (:token-theme-temporary-id file-data)]))) - -(defn add-token-theme - [file-data {:keys [index id] :as token-theme}] - (-> file-data - (update :token-themes - (fn [token-themes] - (let [exists? (some (partial = id) token-themes)] - (cond - exists? token-themes - (nil? index) (conj (or token-themes []) id) - :else (d/insert-at-index token-themes index [id]))))) - (update :token-themes-index assoc id token-theme))) - -(defn update-token-theme - [file-data token-theme-id f & args] - (d/update-in-when file-data [:token-themes-index token-theme-id] #(-> (apply f % args) (touch)))) - -(defn delete-token-theme - [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}] - (-> file-data - (update :token-set-groups - (fn [token-set-groups] - (let [exists? (some (partial = id) token-set-groups)] - (cond - exists? token-set-groups - (nil? index) (conj (or token-set-groups []) id) - :else (d/insert-at-index token-set-groups index [id]))))) - (update :token-sets-index assoc id token-set))) - -(defn update-token-set - [file-data token-set-id f & args] - (d/update-in-when file-data [:token-sets-index token-set-id] #(-> (apply f % args) (touch)))) - -(defn delete-token-set - [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))))))