0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-16 01:31:22 -05:00

Add missing fields on loaded image collections.

This commit is contained in:
Andrey Antukh 2016-09-24 21:17:43 +03:00
parent 6c43164ed1
commit abead1aa9e
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95

View file

@ -45,16 +45,33 @@
(rx/empty))))
(defn initialize
[]
(Initialize.))
[type id]
(Initialize. type id))
;; --- Select a Collection
(defrecord SelectCollection [type id]
rs/WatchEvent
(-apply-watch [_ state stream]
(rx/of (r/navigate :dashboard/images
{:type type :id id}))))
(defn select-collection
([type]
(select-collection type nil))
([type id]
{:pre [(keyword? type)]}
(SelectCollection. type id)))
;; --- Color Collections Fetched
(defrecord CollectionsFetched [items]
rs/UpdateEvent
(-apply-update [_ state]
(reduce (fn [acc {:keys [id] :as item}]
(assoc-in acc [:images-by-id id] item))
(reduce (fn [state item]
(let [id (:id item)
item (assoc item :type :own)]
(assoc-in state [:images-by-id id] item)))
state
items)))
@ -80,10 +97,11 @@
(defrecord CollectionCreated [item]
rs/UpdateEvent
(-apply-update [_ state]
(-> state
(assoc-in [:images-by-id (:id item)] item)
(assoc-in [:dashboard :collection-id] (:id item))
(assoc-in [:dashboard :collection-type] :own))))
(let [item (assoc item :type :own)]
(-> state
(assoc-in [:images-by-id (:id item)] item)
(assoc-in [:dashboard :collection-id] (:id item))
(assoc-in [:dashboard :collection-type] :own)))))
(defn collection-created
[item]