   (reify
     om/IInitState
     (init-state [_]
-      (let [listener-ch (chan)
-            sender-ch (chan)]
-        (make-socket listener-ch sender-ch)
-        {:listener-ch listener-ch
-         :sender-ch sender-ch
-         :text ""}))
+      {:text ""})
+    om/IRenderState
+    (render-state [this {:keys [text] :as state}]
+      (let [sender-ch (:sender-ch app)]
+        (dom/div #js {:className "container"}
+                 (dom/h3 nil "Enter Chat stuff")
+                 (dom/div #js {:className "form-horizontal"}
+                          (dom/div nil
+                                   (dom/div nil
+                                            (om/build users-view (:users app)))
+                                   (dom/div nil
+                                            (om/build chat-view (:original app)))
+                                   (dom/div nil
+                                            (om/build chat-view (:translated app))))
+                          (dom/div #js {:className "form-group"}
+                                   (dom/input #js {:className "form-control" :type "text"
+                                                   :value text
+                                                   :onKeyPress (fn [e] (check-for-enter e owner state app send-message-click))
+                                                   :onChange #(text-entry % owner state)}))
+                          (dom/div #js {:className "col-xs-offset-2 col-xs-10"}
+                                   (dom/button #js {:type "button" :className "button"
+                                                    :onClick (fn [e] (send-message-click sender-ch text owner app))}
+                                               "click me"))))))))
+
+(defn signin-view [app owner]
+  (reify
+    om/IInitState
+    (init-state [_]
+      {:text ""})
+    om/IRenderState
+    (render-state [this {:keys [text] :as state}]
+      (let [sender-ch (:sender-ch app)]
+        (dom/h3 #js {:className "container"}
+                (dom/div #js {:className "form-horizontal"}
+                         (dom/div #js {:className "form-group"}
+                                  (dom/input #js {:className "form-control" :type "text"
+                                                  :value text
+                                                  :onKeyPress (fn [e] (check-for-enter e owner state app login-click))
+                                                  :onChange (fn [e] (text-entry e owner state))}))
+                         (dom/div #js {:className "col-xs-offset-2 col-xs-10"}
+                                  (dom/button #js {:type "button" :className "button"
+                                                   :onClick (fn [e] (login-click sender-ch text owner app))}))))))))
+
+(defn view-picker [app owner]
+  (reify
     om/IWillMount
     (will-mount [_]
-      (let [listener-ch (om/get-state owner :listener-ch)
-            sender-ch (om/get-state owner :sender-ch)]
+      (let [listener-ch (:listener-ch app)
+            sender-ch (:sender-ch app)]
+        (make-socket listener-ch sender-ch)
         (go (loop []
               (let [msg (<! listener-ch)]
                 ;; do something cool with the message
                 (recur))))))
-    om/IRenderState
-    (render-state [this {:keys [sender-ch text] :as state}]
-      (dom/div #js {:className "container"}
-               (dom/h3 nil "Enter Chat stuff")
-               (dom/div #js {:className "form-horizontal"}
-                         (dom/div nil
-                                  (dom/div nil
-                                           (om/build users-view (:users app)))
-                                  (dom/div nil
-                                           (om/build chat-view (:original app)))
-                                  (dom/div nil
-                                           (om/build chat-view (:translated app))))
-                         (dom/div #js {:className "form-group"}
-                                  (dom/input #js {:className "form-control" :type "text"
-                                                  :value text
-                                                  :onKeyPress (fn [e] (check-for-enter e owner state))
-                                                  :onChange #(text-entry % owner state)}))
-                         (dom/div #js {:className "col-xs-offset-2 col-xs-10"}
-                                  (dom/button #js {:type "button" :className "button"
-                                                   :onClick (fn [e] (do
-                                                                     (post-message sender-ch text)
-                                                                     (clear-text owner))
-                                                              )}
-                                              "click me")))))))
+    om/IRender
+    (render [_]
+      (if (empty? (:user-name app))
+        (om/build signin-view app)
+        (om/build master-view app)))))
 
 (om/root
- master-view
+ view-picker
  app-state
  {:target (. js/document (getElementById "app"))})

  #_(put! target text)
  false)

(defn check-for-enter [e owner {:keys [text sender-ch]}]
  (when (or (= 13 (.-keyCode e))
            (= 13 (.-which e)))
    (do
      (post-message sender-ch text)
      clear-text owner)))

(defn text-entry [e owner {:keys [text]}]
  (om/set-state! owner :text (.. e -target -value)))


(def app-state (atom {:original [sample-source]
                      :translated [sample-translation]
                      :users sample-users
                      :user-name nil
                      :listener-ch (chan)
                      :sender-ch (chan)}))

(defn handle-incoming [listener-ch server-ch]
  (go
