             (let [type (:type collection)
                   id (:id collection)]
               (rs/emit! (di/select-collection type id))))]
-    (let [images (count (:images collection))]
+    (let [images (count (:images collection []))]
       [:li {:on-click on-click
             :class-name (when selected? "current")}
        [:span.element-title (:name collection)]

     [:span (:name image)]]))

(mx/defc grid
  {:mixins [mx/static]}
  [state selected {:keys [id type images] :as coll}]
  (let [own? (= type :own)
        ordering (:order state)
        filtering (:filter state)
        images (->> images
                    (remove nil?)
                    (filter-images-by filtering)
                    (sort-images-by ordering))]
    [:div.dashboard-grid-content

  (-> (l/in [:dashboard :images])
      (l/derive st/state)))

(def ^:private collections-ref
  (-> (l/key :image-colls-by-id)
      (l/derive st/state)))

(def ^:private images-ref
  (-> (l/key :images-by-id)
      (l/derive st/state)))

;; (def ^:private collections-ref
;;   (-> (l/lens vals)
;;       (l/derive collections-map-ref)))

;; (defn- focus-collection
;;   [id]
;;   (-> (l/key id)
;;       (l/derive collections-map-ref)))

;; --- Page Title

