 (ns chat.client.views
   (:require [om.core :as om]
             [om.dom :as dom]
+            [clojure.string :as string]
+            [cljs-uuid-utils.core :as uuid]
             [chat.client.dispatcher :refer [dispatch!]]
             [chat.client.store :as store]))
 

                           :onKeyDown
                           (fn [e]
                             (when (and (= 13 e.keyCode) (= e.shiftKey false))
                               (let [text (.. e -target -value)]
                                 (if-let [tag (second (re-matches #"#(.*)" text))]
                                   (dispatch! :tag-thread {:thread-id (config :thread-id)
                                                           :tag-name tag})
                                   (dispatch! :new-message {:thread-id (config :thread-id)
                                                            :content text})))
                               (.preventDefault e)
                               (aset (.. e -target) "value" "")))})))))


    (render [_]
      (dom/div #js {:className "thread"}
        (om/build new-message-view {:placeholder "Start a new conversation..."
                                    :new-thread true
                                    :thread-id (uuid/make-random-squuid)})))))

(defn tag-view [tag owner]
  (reify
