0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-13 16:21:57 -05:00

🐛 Fix icon collection filtering.

This commit is contained in:
Andrey Antukh 2019-11-25 17:08:26 +01:00
parent ffcba0bf22
commit 44a893b46e
3 changed files with 20 additions and 27 deletions

View file

@ -159,7 +159,6 @@
(-> (db/query-one db/pool [sql id user name mdata])
(p/then' decode-row))))
;; --- Mutation: Delete Page
(s/def ::delete-page

View file

@ -46,34 +46,29 @@
;; --- Collections Fetched
(deftype CollectionsFetched [items]
cljs.core/IDeref
(-deref [_] items)
ptk/UpdateEvent
(update [_ state]
(reduce (fn [state {:keys [id user] :as item}]
(let [type (if (uuid/zero? (:user item)) :builtin :own)
item (assoc item :type type)]
(assoc-in state [:icons-collections id] item)))
state
items)))
(defn collections-fetched
[items]
(CollectionsFetched. items))
(ptk/reify ::collections-fetched
cljs.core/IDeref
(-deref [_] items)
ptk/UpdateEvent
(update [_ state]
(reduce (fn [state {:keys [id user] :as item}]
(let [type (if (uuid/zero? (:user-id item)) :builtin :own)
item (assoc item :type type)]
(assoc-in state [:icons-collections id] item)))
state
items))))
;; --- Fetch Collections
(defrecord FetchCollections []
ptk/WatchEvent
(watch [_ state s]
(->> (rp/query! :icons-collections)
(rx/map collections-fetched))))
(defn fetch-collections
[]
(FetchCollections.))
(def fetch-collections
(ptk/reify ::fetch-collections
ptk/WatchEvent
(watch [_ state s]
(->> (rp/query! :icons-collections)
(rx/map collections-fetched)))))
;; --- Collection Created
@ -107,7 +102,7 @@
(defn collections-fetched?
[v]
(instance? CollectionsFetched v))
(= ::collections-fetched (ptk/type v)))
;; --- Collection Updated

View file

@ -424,8 +424,7 @@
(uuid? id) (seek #(= id (:id %)) colls)
:else (first colls))
id (:id selected-coll)]
(mf/use-effect #(st/emit! (di/fetch-collections)))
(mf/use-effect #(st/emit! di/fetch-collections))
(mf/use-effect {:fn #(st/emit! (di/initialize)
(di/fetch-icons id))
:deps #js [id type]})