                (apply dom/div nil
                       (prepare-item (:item/text item)))))))
 
-(defn item-add-view [item owner {:keys [current-item sync]}]
+(defn item-add-view [item owner {:keys [current-item event]}]
   (reify
     om/IRenderState
     (render-state [_ state] ;; keys chan as etc?
       (let [opts {:current-item current-item ;;; XXX
-                  :sync sync}]
+                  :event event}]
         (dom/div #js {:id "item-add-view"}
         (dom/div #js {:id "item-info"}
                  (dom/div #js {:className "item-name editable"}

  (let [value (.. e -target -value)]
    (om/set-state! owner :text text)))

(defn search [owner {:keys [sync current-item]}] ;; XXX: current-item really?
  (let [search (-> (om/get-node owner "search")
                   .-value)]
    (when (and search (not= search ""))
      (put! sync {:op :search :data {:subs search}}))))

(defn search-view [items owner {:keys [current-item sync]}]
  (reify
    om/IRenderState
    (render-state [_ state]
      (let [opts {:current-item current-item ;;; XXX
                  :sync sync}]
        (dom/div #js {:id "search-view"}
                 (dom/p nil "Currently only title's are searchable. It
                 might take a few seconds before entries are

;; =============================================================================
;; Helpers

(defn add-item [item owner {:keys [event current-item]}]
  (let [new-text (-> (om/get-node owner "new-item-text")
                     .-value)
        new-title (-> (om/get-node owner "new-item-title")
                      .-value)]
    (when (and new-title new-text)
      (put! event {:op :create
                  :data {:item/title new-title :item/text new-text}}))))

(defn handle-item-text-change [e owner {:keys [text]}]
