 (defn firebase-swap! [fb-ref f & args]
   (apply m/swap! fb-ref f args))
 
-;; ------------------
-;; logic
+;; -- Helpers ---------------
+
+(defn- random-four-characters []
+  (->> (repeatedly #(rand-nth ["a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z"]))
+       (take 4)
+       (str/join)
+       (str/upper-case)))
 
 (defn join-room [id]
   (reset! chat-room id)

            [reagent.core :as reagent]
            [reagent.session :as session]
            [secretary.core :as secretary :include-macros true]
            [matchbox.async :as ma]
            [matchbox.core :as m])
  (:require-macros [cljs.core.async.macros :refer [go go-loop]])
  (:import goog.History))

;; -----------------------------
;; Global Data

;; -- REPLACE with your own DB location ---------
(def firebase-io-root "https://shining-torch-2145.firebaseIO.com")
;; ----------------------------------------------

(defonce show-state? (reagent/atom true))
(defonce username (reagent/atom "username"))
(defonce chat-room (reagent/atom nil))

(defonce fb-messages (atom nil))
(defonce messages (reagent/atom []))

(defn random-four-characters []
  (->> (repeatedly #(rand-nth ["a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z"]))
       (take 4)
       (str/join)
       (str/upper-case)))

;; -----------------------------
;; Firebase helpers

(defn bind-to-ratom [ratom ref & [korks]]
  (let [ch (ma/listen-to< ref korks :value)]

      [on-going-chat]
      [join-room-view])

    [:div [:br] [:br] [:br]
     "STATE!!!!"
     [:div "Messages: " (pr-str @messages)]]]])

(defn current-page []
  [:div [(session/get :current-page)]])

;; -------------------------
;; Routes

(secretary/defroute "/" []
  (reset! chat-room nil)
