mirror of
https://github.com/penpot/penpot.git
synced 2025-06-06 15:31:38 +02:00
Replace random-uuid
usage with uuid.core/random
.
This commit is contained in:
parent
f102be51cb
commit
f0ed85e53f
5 changed files with 14 additions and 9 deletions
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
(ns uxbox.data.dashboard
|
(ns uxbox.data.dashboard
|
||||||
(:require [beicon.core :as rx]
|
(:require [beicon.core :as rx]
|
||||||
|
[uuid.core :as uuid]
|
||||||
[uxbox.rstore :as rs]
|
[uxbox.rstore :as rs]
|
||||||
[uxbox.router :as r]
|
[uxbox.router :as r]
|
||||||
[uxbox.state :as st]
|
[uxbox.state :as st]
|
||||||
|
@ -102,7 +103,7 @@
|
||||||
(reify
|
(reify
|
||||||
rs/UpdateEvent
|
rs/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(-apply-update [_ state]
|
||||||
(let [id (random-uuid)
|
(let [id (uuid/random)
|
||||||
coll {:name "Unnamed collection"
|
coll {:name "Unnamed collection"
|
||||||
:id id :colors #{}}]
|
:id id :colors #{}}]
|
||||||
(-> state
|
(-> state
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
(ns uxbox.data.shapes
|
(ns uxbox.data.shapes
|
||||||
(:require [beicon.core :as rx]
|
(:require [beicon.core :as rx]
|
||||||
|
[uuid.core :as uuid]
|
||||||
[uxbox.constants :as c]
|
[uxbox.constants :as c]
|
||||||
[uxbox.rstore :as rs]
|
[uxbox.rstore :as rs]
|
||||||
[uxbox.router :as r]
|
[uxbox.router :as r]
|
||||||
|
@ -392,7 +393,7 @@
|
||||||
rs/UpdateEvent
|
rs/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(-apply-update [_ state]
|
||||||
(let [shapes-by-id (get state :shapes-by-id)
|
(let [shapes-by-id (get state :shapes-by-id)
|
||||||
sid (random-uuid)
|
sid (uuid/random)
|
||||||
pid (get-in state [:workspace :page])
|
pid (get-in state [:workspace :page])
|
||||||
selected (get-in state [:workspace :selected])
|
selected (get-in state [:workspace :selected])
|
||||||
selected' (map #(get shapes-by-id %) selected)
|
selected' (map #(get shapes-by-id %) selected)
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
(ns uxbox.data.workspace
|
(ns uxbox.data.workspace
|
||||||
(:require [beicon.core :as rx]
|
(:require [beicon.core :as rx]
|
||||||
|
[uuid.core :as uuid]
|
||||||
[uxbox.constants :as c]
|
[uxbox.constants :as c]
|
||||||
[uxbox.rstore :as rs]
|
[uxbox.rstore :as rs]
|
||||||
[uxbox.state.shapes :as stsh]
|
[uxbox.state.shapes :as stsh]
|
||||||
|
@ -133,7 +134,7 @@
|
||||||
rs/UpdateEvent
|
rs/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(-apply-update [_ state]
|
||||||
(let [selected (get-in state [:workspace :selected])
|
(let [selected (get-in state [:workspace :selected])
|
||||||
item {:id (random-uuid)
|
item {:id (uuid/random)
|
||||||
:created-at (dt/now)
|
:created-at (dt/now)
|
||||||
:items selected}
|
:items selected}
|
||||||
clipboard (-> (:clipboard state)
|
clipboard (-> (:clipboard state)
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
(ns uxbox.state.shapes
|
(ns uxbox.state.shapes
|
||||||
"A collection of functions for manage shapes insinde the state."
|
"A collection of functions for manage shapes insinde the state."
|
||||||
(:require [uxbox.util.data :refer (index-of)]
|
(:require [uuid.core :as uuid]
|
||||||
|
[uxbox.util.data :refer (index-of)]
|
||||||
[uxbox.util.geom :as geom]))
|
[uxbox.util.geom :as geom]))
|
||||||
|
|
||||||
;; --- Shape Creation
|
;; --- Shape Creation
|
||||||
|
|
||||||
(defn assoc-shape-to-page
|
(defn assoc-shape-to-page
|
||||||
[state shape page]
|
[state shape page]
|
||||||
(let [sid (random-uuid)
|
(let [sid (uuid/random)
|
||||||
shape (merge shape {:id sid :page page})]
|
shape (merge shape {:id sid :page page})]
|
||||||
(as-> state $
|
(as-> state $
|
||||||
(update-in $ [:pages-by-id page :shapes] #(into [] (cons sid %)))
|
(update-in $ [:pages-by-id page :shapes] #(into [] (cons sid %)))
|
||||||
|
@ -19,7 +20,7 @@
|
||||||
([state shapes page group]
|
([state shapes page group]
|
||||||
(letfn [(duplicate-shape [state shape page group]
|
(letfn [(duplicate-shape [state shape page group]
|
||||||
(if (= (:type shape) :group)
|
(if (= (:type shape) :group)
|
||||||
(let [id (random-uuid)
|
(let [id (uuid/random)
|
||||||
items (:items shape)
|
items (:items shape)
|
||||||
shape (assoc shape :id id :page page :items [])
|
shape (assoc shape :id id :page page :items [])
|
||||||
state (if (nil? group)
|
state (if (nil? group)
|
||||||
|
@ -31,7 +32,7 @@
|
||||||
(assoc-in $ [:shapes-by-id id] shape)))]
|
(assoc-in $ [:shapes-by-id id] shape)))]
|
||||||
(->> (map #(get-in state [:shapes-by-id %]) items)
|
(->> (map #(get-in state [:shapes-by-id %]) items)
|
||||||
(reduce #(duplicate-shape %1 %2 page id) state)))
|
(reduce #(duplicate-shape %1 %2 page id) state)))
|
||||||
(let [id (random-uuid)
|
(let [id (uuid/random)
|
||||||
shape (-> (dissoc shape :group)
|
shape (-> (dissoc shape :group)
|
||||||
(assoc :id id :page page)
|
(assoc :id id :page page)
|
||||||
(merge (when group {:group group})))]
|
(merge (when group {:group group})))]
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
(ns uxbox.util.workers
|
(ns uxbox.util.workers
|
||||||
"A lightweight layer on top of webworkers api."
|
"A lightweight layer on top of webworkers api."
|
||||||
(:require [beicon.core :as rx]
|
(:require [beicon.core :as rx]
|
||||||
|
[uuid.core :as uuid]
|
||||||
[uxbox.util.transit :as t]))
|
[uxbox.util.transit :as t]))
|
||||||
|
|
||||||
;; --- Implementation
|
;; --- Implementation
|
||||||
|
@ -18,7 +19,7 @@
|
||||||
(deftype WebWorker [stream wrk]
|
(deftype WebWorker [stream wrk]
|
||||||
IWorker
|
IWorker
|
||||||
(-ask [this message]
|
(-ask [this message]
|
||||||
(let [sender (random-uuid)
|
(let [sender (uuid/random)
|
||||||
data (assoc message :sender sender)
|
data (assoc message :sender sender)
|
||||||
data (t/encode data)]
|
data (t/encode data)]
|
||||||
(.postMessage wrk data)
|
(.postMessage wrk data)
|
||||||
|
@ -27,7 +28,7 @@
|
||||||
(rx/take 1))))
|
(rx/take 1))))
|
||||||
|
|
||||||
(-send [this message]
|
(-send [this message]
|
||||||
(let [sender (random-uuid)
|
(let [sender (uuid/random)
|
||||||
data (assoc message :sender sender)
|
data (assoc message :sender sender)
|
||||||
data (t/encode data)]
|
data (t/encode data)]
|
||||||
(.postMessage wrk data)
|
(.postMessage wrk data)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue