                                       (not (contains? @open-thread-ids (thread :id)))))
                        (vals @threads)))))))
 
-(reg-sub-raw
+(reg-sub
   :users-in-group
   (fn [state [_ group-id]]
-    (reaction
-      (->> (@state :users)
-           vals
-           (filter (fn [u] (contains? (set (u :group-ids)) group-id)))
-           doall))))
+    (->> (state :users)
+         vals
+         (filter (fn [u] (contains? (set (u :group-ids)) group-id)))
+         doall)))
 
 (reg-sub-raw
   :users-in-open-group

    ; depend on page & group, so when the page changes this sub updates too
    (.getPath (.parse Uri js/window.location))))

(reg-sub-raw
  :thread
  (fn [state _ [thread-id]]
    (reaction (get-in @state [:threads thread-id]))))

(reg-sub-raw
  :threads
  (fn [state _]
    (reaction (@state :threads))))

(reg-sub-raw
  :page-id
  (fn [state _]
    (reaction (get-in @state [:page :id]))))

(reg-sub-raw
  :open-threads

                                    @mention-ids)))]
      mentions)))

(reg-sub
  :messages-for-thread
  (fn [state [_ thread-id]]
    (get-in state [:threads thread-id :messages])))

(reg-sub
  :thread-open?
  (fn [state [_ thread-id]]
    (contains? (set (get-in state [:user :open-thread-ids])) thread-id)))

(reg-sub
  :thread-focused?
  (fn [state [_ thread-id]]
    (= thread-id (get-in state [:focused-thread-id]))))

(reg-sub
  :thread-last-open-at
  (fn [state [_ thread-id]]
    (get-in state [:threads thread-id :last-open-at])))

(reg-sub
  :thread-new-message
  (fn [state _ [thread-id]]
    (if-let [th (get-in state [:threads thread-id])]
      (get th :new-message "")
      (get-in state [:new-thread-msg thread-id] ""))))

(reg-sub
  :errors
  (fn [state _]
    (get-in state [:errors])))

(reg-sub
  :login-state
  (fn [state _]
    (get-in state [:login-state])))

(reg-sub
  :tag
  (fn [state _ [tag-id]]
    (get-in state [:tags tag-id])))

(reg-sub
  :nickname
  (fn [state _ [user-id]]
    (get-in state [:users user-id :nickname])))

(reg-sub
  :invitations
  (fn [state _]
    (get-in state [:invitations])))

(reg-sub
  :pagination-remaining
  (fn [state _]
    (state :pagination-remaining)))

(reg-sub
  :user-subscribed-tag-ids
  (fn [state _]
    (set (get-in state [:user :subscribed-tag-ids]))))

(reg-sub
  :connected?
  (fn [state _]
    (not-any? (fn [[k _]] (= :disconnected k)) (state :errors))))

(reg-sub
  :new-thread-id
  (fn [state _]
    (get state :new-thread-id)))

(reg-sub
  :user-preference
  (fn [state [_ pref]]
    (get-in state [:preferences pref])))

(reg-sub
  :tags-in-group
