0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-14 08:41:48 -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
backend/src/uxbox/services
frontend/src/uxbox/main
data
ui/dashboard

View file

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

View file

@ -46,34 +46,29 @@
;; --- Collections Fetched ;; --- 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 (defn collections-fetched
[items] [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 ;; --- Fetch Collections
(defrecord FetchCollections [] (def fetch-collections
ptk/WatchEvent (ptk/reify ::fetch-collections
(watch [_ state s] ptk/WatchEvent
(->> (rp/query! :icons-collections) (watch [_ state s]
(rx/map collections-fetched)))) (->> (rp/query! :icons-collections)
(rx/map collections-fetched)))))
(defn fetch-collections
[]
(FetchCollections.))
;; --- Collection Created ;; --- Collection Created
@ -107,7 +102,7 @@
(defn collections-fetched? (defn collections-fetched?
[v] [v]
(instance? CollectionsFetched v)) (= ::collections-fetched (ptk/type v)))
;; --- Collection Updated ;; --- Collection Updated

View file

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