diff --git a/backend/src/uxbox/services/pages.clj b/backend/src/uxbox/services/pages.clj index 00667307e..30b64c7db 100644 --- a/backend/src/uxbox/services/pages.clj +++ b/backend/src/uxbox/services/pages.clj @@ -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 diff --git a/frontend/src/uxbox/main/data/icons.cljs b/frontend/src/uxbox/main/data/icons.cljs index 4c7b3e59d..99c813f98 100644 --- a/frontend/src/uxbox/main/data/icons.cljs +++ b/frontend/src/uxbox/main/data/icons.cljs @@ -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 diff --git a/frontend/src/uxbox/main/ui/dashboard/icons.cljs b/frontend/src/uxbox/main/ui/dashboard/icons.cljs index 39ebbb242..32d80e077 100644 --- a/frontend/src/uxbox/main/ui/dashboard/icons.cljs +++ b/frontend/src/uxbox/main/ui/dashboard/icons.cljs @@ -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]})