 (reg-event-fx
   :set-group-intro
   (fn [{state :db :as cofx} [_ {:keys [group-id intro local-only?] :as args}]]
-    (merge
-      {:db (helpers/set-group-intro state group-id intro)}
-      (when-not local-only?
-        {:websocket-send (list [:braid.server/set-group-intro args])}))))
+    {:db (helpers/set-group-intro state group-id intro)
+     :websocket-send (when-not local-only?
+                       (list [:braid.server/set-group-intro args]))}))
 
 (reg-event-fx
   :set-group-avatar
   (fn [{state :db :as cofx} [_ {:keys [group-id avatar local-only?] :as args}]]
-    (merge
-      {:db (helpers/set-group-avatar state group-id avatar)}
-      (when-not local-only?
-        {:websocket-send (list [:braid.server/set-group-avatar args])}))))
+    {:db (helpers/set-group-avatar state group-id avatar)
+     :websocket-send (when-not local-only?
+                       (list [:braid.server/set-group-avatar args]))}))
 
 (reg-event-fx
   :make-group-public!

(reg-event-fx
  :subscribe-to-tag
  (fn [{state :db :as cofx} [_ {:keys [tag-id local-only?]}]]
    (merge
      {:db (helpers/subscribe-to-tag state tag-id)}
      (when-not local-only?
        {:websocket-send (list [:braid.server/subscribe-to-tag tag-id])}))))

(reg-event-fx
  :set-tag-description
  (fn [{state :db :as cofx} [_ {:keys [tag-id description local-only?]}]]
    (merge
      {:db (helpers/set-tag-description state tag-id description)}
      (when-not local-only?
        {:websocket-send
         (list
           [:braid.server/set-tag-description {:tag-id tag-id
                                               :description description}])}))))

(reg-event-fx
  :remove-tag
  (fn [{state :db :as cofx} [_ {:keys [tag-id local-only?]}]]
    (merge
      {:db (helpers/remove-tag state tag-id)}
      (when-not local-only?
        {:websocket-send (list [:braid.server/retract-tag tag-id])}))))

(reg-event-db
  :remove-group

(reg-event-fx
  :leave-group
  (fn [{state :db :as cofx} [_ {:keys [group-id group-name]}]]
    {:db
     (-> state
         (helpers/display-error (str "left-" group-id)
                                (str "You have been removed from " group-name)
                                :info)
         (helpers/remove-group group-id)
         ((fn [state]
            (if-let [sidebar-order (:groups-order
                                     (helpers/get-user-preferences state))]
              (helpers/set-preferences
                state
                {:groups-order (into [] (remove (partial = group-id))
                                     sidebar-order)})
              state))))
     :redirect-to (when (= group-id (helpers/get-open-group-id state))
                    "/")}))

(reg-event-db
  :add-open-thread
