       (println (str "Num of file downloads: " (:num-of-downloads @app-state))))
     (println "WARNING: Attempted to request download that has already been requested")))
 
+(defn indices [pred coll]
+  (keep-indexed #(when (pred %2) %1) coll))
+
 ; TODO: reimplement this
 (defn get-next-track-to-download []
   nil)


(defn resume []
  (.emit socket "resume"))

(defn indices [pred coll]
  (keep-indexed #(when (pred %2) %1) coll))

(defn get-current-track-num []
  (first (indices #(= (.-id %1) (:current-track-id @app-state))


(.on socket "hotjoin-music-info"
  (fn [room-music-info track-order current-track-id current-sound-id]
    (let [track-order (js->clj track-order)
          sorted-music-info (.sort room-music-info (fn [a b]
                                                     (- (indices #(= %1 (.-id a)) track-order)
                                                        (indices #(= %1 (.-id b)) track-order))))]

      (swap! app-state assoc :track-order track-order)
      (swap! app-state assoc :music-info (vec (map #(clj->js %1)
                                                (js->clj sorted-music-info)))))

    (swap! app-state assoc :current-track-id current-track-id)
    (swap! app-state assoc :current-sound-id current-sound-id)

