          [comment-list (vec kids)])])))
 
 (defn story-list-item [story]
-  (let [{:keys [by id title score url kids]} story]
+  (let [{:keys [by id title score url kids]} @story]
     (when (every? identity [by title score])
       [:div
        [:p [:a {:href url} title]]

(defn main-page [state]
  [:div
   [nav]
   (page @state)])

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

                :style {:cursor :pointer}}
         [:i "Preview"]]]])))

(defn top-stories [stories]
  [:ol
   (for [[index entry] (into (sorted-map) @stories)]
     ^{:key index}
     [:li [story-list-item
           (r/wrap entry
                   swap! stories assoc index)]])])

;; -------------------------
;; Views
(defmulti page #(:render-view (deref %)))

(defmethod page nil [_]
  [:div "Invalid/Unknown route"])

(defmethod page :main [state]
  [top-stories (r/wrap (:top-stories @state)
                       swap! app-state assoc :top-stories)])

(defmethod page :item [state]
  (when-let [entry (get-in @state [:current-item])]
    (case (:type entry)
      "story" [story entry]
      "comment" [comment entry]
