      [:span (:name image)]]))
 
 (mx/defc grid
-  {:mixins [mx/static]}
-  [state selected {:keys [id type images] :as coll}]
-  (let [own? (= type :own)
+  {:mixins [mx/static mx/reactive]}
+  [{:keys [id type  selected] :as state}]
+  (let [filtering (:filter state)
         ordering (:order state)
-        filtering (:filter state)
-        images (->> images
-                    (remove nil?)
+        own? (= type :own)
+        images (rum/react images-ref)
+        images (->> (vals images)
+                    (filter #(= id (:collection %)))
                     (filter-images-by filtering)
                     (sort-images-by ordering))]
     [:div.dashboard-grid-content


(mx/defc content
  {:mixins [mx/static]}
  [state coll]
  (let [selected (:selected state)
        coll-type (:type coll)
        own? (= coll-type :own)]
    (when coll
      [:section.dashboard-grid.library
       (page-title coll)
       (grid state selected coll)
       (when (and (seq selected))
         (grid-options coll))])))

;; --- Menu

(mx/defc menu
  {:mixins [mx/static]}
  [state coll]
  (let [ordering (:order state :name)
        filtering (:filter state "")
        icount (count (:images coll))]
    (letfn [(on-term-change [event]

           (mx/with-key key)))]))

(mx/defc nav
  {:mixins [mx/static]}
  [{:keys [type id] :as state} colls]
  (let [own? (= type :own)
        builtin? (= type :builtin)]
    (letfn [(select-tab [type]
              (let [xf (comp
                        (map second)
                        (filter #(= type (:type %))))
                    colls (into [] xf colls)
                    colls (sort-by :id colls)]
                (if-let [item (first colls)]
                  (rs/emit! (di/select-collection type (:id item)))
                  (rs/emit! (di/select-collection type)))))]
