   (helpers/focus-thread state thread-id))
 
 (defmethod handler :clear-inbox [state [_ _]]
-  (let [open-thread-ids (map :id (helpers/get-open-threads state))]
-    (doseq [id open-thread-ids]
-      (dispatch! :hide-thread {:thread-id id :local-only? false})))
-  state)
+  (->> (helpers/get-open-threads state)
+       (map :id )
+       (reduce (fn [state id]
+                 (handler state [:hide-thread {:thread-id id :local-only? false}]))
+               state)))
 
 (defmethod handler :invite [state [_ data]]
   (let [invite (schema/make-invitation data)]

(defmethod handler :create-upload [state [_ {:keys [url thread-id group-id]}]]
  (sync/chsk-send! [:braid.server/create-upload
                    (schema/make-upload {:url url :thread-id thread-id})])
  (dispatch! :new-message {:content url :thread-id thread-id :group-id group-id})
  state)

(defmethod handler :get-group-uploads [state [_ {:keys [group-id on-success on-error]}]]
  (sync/chsk-send!


(defmethod handler :add-notification-rule [state [_ rule]]
  (let [current-rules (get (helpers/get-user-preferences state) :notification-rules [])]
    (handler state [:set-preference [:notification-rules (conj current-rules rule)]])))

(defmethod handler :remove-notification-rule [state [_ rule]]
  (let [new-rules (->> (get (helpers/get-user-preferences state) :notification-rules [])
                       (into [] (remove (partial = rule))))]
    (handler state [:set-preference [:notification-rules new-rules]])))

(defmethod handler :clear-search-error [state _]
  (helpers/clear-search-error state))
