 
 (def check-app-state! (s/validator AppState))
 
-(defn- key-by-id [coll]
-  (into {} (map (juxt :id identity)) coll))
-
 (defn transact! [v]
   (let [old-state @app-state]
     (reset! app-state v)

         first
         :id)))

(defn get-tag [tag-id]
  (get-in @app-state [:tags tag-id]))

(defn is-subscribed-to-tag? [tag-id]
  (contains? (get-in @app-state [:user :subscribed-tag-ids]) tag-id))

(defn open-group-name []
  (let [st @app-state]
    (get-in st [:groups (st :open-group-id) :name])))

(defn id->group [group-id]
  (get-in @app-state [:groups group-id]))

(defn bots-in-open-group []
  (get-in @app-state [:groups (get @app-state :open-group-id) :bots]))

(defn open-group-id []
  (get @app-state :open-group-id))

      (catch ExceptionInfo e
        (errorf "State consistency error: %s"
                (:error (ex-data e)))
        (println (ex-data e))
        (reset! app-state old-state)
        ; Not just calling display-error! to avoid possibility of infinite loop
        (swap! app-state update-in [:errors] conj
