     (sync/chsk-send! [:braid.server/show-thread thread-id])
     (helpers/show-thread state thread-id)))
 
-(reg-event-db
+(reg-event-fx
   :unsub-thread
-  (fn [state [_ data]]
+  (fn [cofx [_ data]]
     ; TODO
     (sync/chsk-send! [:braid.server/unsub-thread (data :thread-id)])
-    ; TODO
-    (handler state [:hide-thread {:thread-id (data :thread-id) :local-only? true}])))
+    {:dispatch [:hide-thread {:thread-id (data :thread-id) :local-only? true}]}))
 
 (reg-event-db
   :create-tag

  (fn [state [_ thread-id]]
    (helpers/focus-thread state thread-id)))

(reg-event-db
  :clear-inbox
  (fn [state [_ _]]
    (->> (helpers/get-open-threads state)
         (map :id)
         (reduce (fn [state id]
                   ; TODO
                   (handler state [:hide-thread {:thread-id id :local-only? false}]))
                 state))))

(reg-event-db
  :invite

          true (on-success))))
    state))

(reg-event-fx
  :add-notification-rule
  (fn [{state :db :as cofx} [_ rule]]
    (let [current-rules (get (helpers/get-user-preferences state) :notification-rules [])]
      {:dispatch [:set-preference [:notification-rules (conj current-rules rule)]]})))

(reg-event-db
  :remove-notification-rule
  (fn [{state :db :as cofx} [_ rule]]
    (let [new-rules (->> (get (helpers/get-user-preferences state) :notification-rules [])
                         (into [] (remove (partial = rule))))]
      {:dispatch [:set-preference [:notification-rules new-rules]]})))

(reg-event-db
  :set-search-results
