                (fn [e]
                  (let [div (.. e -target)]
                    (when (and (= status :done-results)
-                           (< (count @loaded-threads) (count (@page :thread-ids)))
+                           (< (count loaded-threads) (count (@page :thread-ids)))
                            (> 100 (- (.-scrollWidth div)
                                      (+ (.-scrollLeft div) (.-offsetWidth div)))))
                      (dispatch [:set-page-loading true])
-                     (let [already-have (set (map :id @loaded-threads))
+                     (let [already-have (set (map :id loaded-threads))
                            to-load (->> (@page :thread-ids)
                                         (remove already-have)
                                         (take 25))]

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


             "Try again"]]]

          (:done-results :loading)
          (let [loaded-threads (vals (select-keys @threads (@page :thread-ids)))
                sorted-threads (->> loaded-threads
                                    ; sort-by last reply, newest first
                                    (sort-by
                                      (comp (partial apply max)
                                            (partial map :created-at)
                                            :messages)
                                      #(compare %2 %1)))]
            [:div.page.search
             [:div.title (str "Search for \"" @query "\"")]
             [:div.content
              [:div.description
               (if (= status :loading)
                 "Loading more results..."
                 (str "Displaying " (count loaded-threads) "/"
                      (count (@page :thread-ids))))]]
             [:div.threads
              {:ref "threads-div"
