                    (rx/map (partial vector file))))
             (allowed-file? [file]
               (contains? allowed-file-types (.-type file)))
+            (finalize-upload []
+              (assoc-in state [:dashboard :images :uploading] false))
             (prepare [[file [width height]]]
               {:collection id
                :mimetype (.-type file)

               :height height})]
      (->> (rx/from-coll (jscoll->vec files))
           (rx/filter allowed-file?)
           (rx/flat-map image-size)
           (rx/map prepare)
           (rx/flat-map #(rp/req :create/image %))
           (rx/map :payload)
           (rx/map image-created)))))

(defn create-images
  [id files]
  {:pre [(or (uuid? id) (nil? id))]}
  (CreateImages. id files))

;; --- Image Updated



(def allowed-file-types #{"image/jpeg" "image/png"})

(defrecord CreateImages [id files on-uploaded]
  rs/UpdateEvent
  (-apply-update [_ state]
    (assoc-in state [:dashboard :images :uploading] true))

  rs/WatchEvent
  (-apply-watch [_ state s]
    (letfn [(image-size [file]
