 (register-sub
   :chat-room-messages
   (fn [db _]
-    (reaction (:messages @db))))
+    (reaction (vals (:messages @db)))))
 
 ;; -- Event Handlers --------
 

  :join-chat-room
  (fn [db [_ room-id]]
    ;; listen to chat room on firebase
    (let [id          (-> room-id (str/lower-case) (keyword))
          fb-messages (m/get-in fb-root [id :messages])]
      (m/listen-to fb-messages :value
                     (fn [[_ v]] (println v) (dispatch [:room-update v]))))

    ;; update current room id
    (assoc db :chat-room room-id)))

(defn show-messages []
  (let [messages (subscribe [:chat-room-messages])]
    [:div#messages
     (for [[{:keys [username message]} index] (map vector @messages (range))]
       ^{:key (str "message-" index)}
       [:div [:span.username username] ": " [:span.message message]])]))

;; -- Views -----------------

