                  :onKeyPress #(when (== (.-keyCode %) 13) (send-msg app owner))}]
         [:button {:on-click #(send-msg app owner)} "Send"]]))))
 
-(defn channel-view [channel owner]
+(defn channel-view [cursor owner]
   (reify
     om/IRender
     (render [this]
-      (sab/html
-       [:div {:class (if (= (:active-channel @app-state) channel) "active" "")
-              :on-click #(swap! app-state assoc :active-channel channel)}
-         (str "#" (name channel))]))))
+      (let [ch (:channel cursor)
+            active-ch (:active-channel cursor)]
+       (sab/html
+        [:div {:class (if (= (first active-ch) ch) "active" "")
+               :on-click #(om/update! active-ch [ch])}
+         (str "#" (name ch))])))))
 
 (defn channel-list-view [app owner]
   (reify

    (render-state [this state]
      (sab/html
       [:div.blue-shade.panel.channel-list
        (om/build-all channel-view (keys (:channels app)))]))))

(defn message-view [message owner]
  (reify

       [:div.chat-app
        (om/build channel-list-view app)
        [:div.chat-box
         (om/build message-list-view (get-in app [:channels (first (:active-channel app))]))
         (om/build msg-input-view app)]]))))

(om/root chat-app app-state {:target (. js/document (getElementById "chat"))})
