   (:require [om.core :as om]
             [om.dom :as dom]
             [reagent.core :as r]
+            [reagent.ratom :include-macros true :refer-macros [reaction]]
             [braid.ui.views.thread :refer [thread-view]]
             [chat.client.dispatcher :refer [dispatch!]]
             [chat.client.reagent-adapter :refer [subscribe]]

                               (- (.-scrollLeft this-elt) (.-deltaY e))))))}
                  (doall
                    (for [thread @sorted-threads]
                     ^{:key [thread :id]}
                     [thread-view thread]))]])

            :done-empty
            [:div.content

                "Searching..."]]

            (:done-results :loading)
            (let [loaded-threads (reaction (vals (select-keys @threads (@page :thread-ids))))
                  sorted-threads (reaction (->> @threads ; sort-by last reply, newest first
                                               vals
                                                (sort-by
                                                (comp (partial apply max)
                                                      (partial map :created-at)
                                                      :messages))
                                                reverse))]
              [:div.content
                [:div.description
                  (if (= status :loading)
