From bfa90d0347f3f5ff38e82585ca0a2d14c8f2becd Mon Sep 17 00:00:00 2001 From: Florian Schroedl Date: Mon, 30 Sep 2024 15:18:26 +0200 Subject: [PATCH] Fix duplicate token event --- frontend/src/app/main/data/tokens.cljs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/main/data/tokens.cljs b/frontend/src/app/main/data/tokens.cljs index 9b0d59191..79d771671 100644 --- a/frontend/src/app/main/data/tokens.cljs +++ b/frontend/src/app/main/data/tokens.cljs @@ -239,11 +239,16 @@ (rx/of (dch/commit-changes changes)))))) (defn duplicate-token - [id] - (let [new-token (-> (get-token-data-from-token-id id) - (dissoc :id) - (update :name #(str/concat % "-copy")))] - (update-create-token new-token))) + [token-name] + (dm/assert! (string? token-name)) + (ptk/reify ::duplicate-token + ptk/WatchEvent + (watch [_ state _] + (when-let [token (some-> (wtts/get-selected-token-set state) + (ctob/get-token token-name) + (update :name #(str/concat % "-copy")))] + (rx/of + (update-create-token token)))))) (defn set-token-type-section-open [token-type open?]