mirror of
https://github.com/heyarne/airsonic-ui.git
synced 2026-05-06 18:33:38 +02:00
Remove accidental double question mark from currently-playing keyword
This commit is contained in:
parent
bac22c03a1
commit
840c7edb79
1 changed files with 19 additions and 19 deletions
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
(defn- mark-first-song [queue]
|
(defn- mark-first-song [queue]
|
||||||
(let [[first-idx _] (find-where #(= 0 (:playlist/order %)) queue)]
|
(let [[first-idx _] (find-where #(= 0 (:playlist/order %)) queue)]
|
||||||
(assoc-in queue [first-idx :playlist/currently-playing??] true)))
|
(assoc-in queue [first-idx :playlist/currently-playing?] true)))
|
||||||
|
|
||||||
(defmethod ->playlist :linear
|
(defmethod ->playlist :linear
|
||||||
[queue & {:keys [playback-mode repeat-mode]}]
|
[queue & {:keys [playback-mode repeat-mode]}]
|
||||||
|
|
@ -33,17 +33,17 @@
|
||||||
(defmethod ->playlist :shuffled
|
(defmethod ->playlist :shuffled
|
||||||
[queue & {:keys [playback-mode repeat-mode]}]
|
[queue & {:keys [playback-mode repeat-mode]}]
|
||||||
(let [queue (conj (mapv #(update % :playlist/order inc) (-shuffle-songs (rest queue)))
|
(let [queue (conj (mapv #(update % :playlist/order inc) (-shuffle-songs (rest queue)))
|
||||||
(assoc (first queue) :playlist/order 0 :playlist/currently-playing?? true))]
|
(assoc (first queue) :playlist/order 0 :playlist/currently-playing? true))]
|
||||||
(->Playlist queue playback-mode repeat-mode)))
|
(->Playlist queue playback-mode repeat-mode)))
|
||||||
|
|
||||||
(defn set-current-song
|
(defn set-current-song
|
||||||
"Marks a song in the queue as currently playing, given its ID"
|
"Marks a song in the queue as currently playing, given its ID"
|
||||||
[playlist next-idx]
|
[playlist next-idx]
|
||||||
(let [[current-idx _] (find-where :playlist/currently-playing?? (:queue playlist))]
|
(let [[current-idx _] (find-where :playlist/currently-playing? (:queue playlist))]
|
||||||
(-> (if current-idx
|
(-> (if current-idx
|
||||||
(update-in playlist [:queue current-idx] dissoc :playlist/currently-playing??)
|
(update-in playlist [:queue current-idx] dissoc :playlist/currently-playing?)
|
||||||
playlist)
|
playlist)
|
||||||
(assoc-in [:queue next-idx :playlist/currently-playing??] true))))
|
(assoc-in [:queue next-idx :playlist/currently-playing?] true))))
|
||||||
|
|
||||||
(defn set-playback-mode
|
(defn set-playback-mode
|
||||||
"Changes the playback mode of a playlist and re-shuffles it if necessary"
|
"Changes the playback mode of a playlist and re-shuffles it if necessary"
|
||||||
|
|
@ -52,12 +52,12 @@
|
||||||
;; for shuffled playlists we reorder the songs make sure that the currently
|
;; for shuffled playlists we reorder the songs make sure that the currently
|
||||||
;; playing song has order 0
|
;; playing song has order 0
|
||||||
(let [playlist (->playlist (:queue playlist) :playback-mode playback-mode :repeat-mode (:repeat-mode playlist))
|
(let [playlist (->playlist (:queue playlist) :playback-mode playback-mode :repeat-mode (:repeat-mode playlist))
|
||||||
[current-idx current-song] (find-where :playlist/currently-playing?? (:queue playlist))
|
[current-idx current-song] (find-where :playlist/currently-playing? (:queue playlist))
|
||||||
[swap-idx _] (find-where #(= 0 (:playlist/order %)) (:queue playlist))]
|
[swap-idx _] (find-where #(= 0 (:playlist/order %)) (:queue playlist))]
|
||||||
(-> (assoc-in playlist [:queue current-idx :playlist/order] 0)
|
(-> (assoc-in playlist [:queue current-idx :playlist/order] 0)
|
||||||
(assoc-in [:queue swap-idx :playlist/order] (:playlist/order current-song))))
|
(assoc-in [:queue swap-idx :playlist/order] (:playlist/order current-song))))
|
||||||
;; for linear songs we just make sure that the current does not change
|
;; for linear songs we just make sure that the current does not change
|
||||||
(let [[current-idx _] (find-where :playlist/currently-playing?? (:queue playlist))]
|
(let [[current-idx _] (find-where :playlist/currently-playing? (:queue playlist))]
|
||||||
(-> (->playlist (:queue playlist) :playback-mode playback-mode :repeat-mode (:repeat-mode playlist))
|
(-> (->playlist (:queue playlist) :playback-mode playback-mode :repeat-mode (:repeat-mode playlist))
|
||||||
(set-current-song current-idx)))))
|
(set-current-song current-idx)))))
|
||||||
|
|
||||||
|
|
@ -70,7 +70,7 @@
|
||||||
"Returns the song in a playlist that is currently playing"
|
"Returns the song in a playlist that is currently playing"
|
||||||
[playlist]
|
[playlist]
|
||||||
(->> (:queue playlist)
|
(->> (:queue playlist)
|
||||||
(filter :playlist/currently-playing??)
|
(filter :playlist/currently-playing?)
|
||||||
(first)))
|
(first)))
|
||||||
|
|
||||||
(defmulti next-song "Advances the currently playing song" :repeat-mode)
|
(defmulti next-song "Advances the currently playing song" :repeat-mode)
|
||||||
|
|
@ -78,44 +78,44 @@
|
||||||
(defmethod next-song :repeat-none
|
(defmethod next-song :repeat-none
|
||||||
[playlist]
|
[playlist]
|
||||||
;; this is pretty easy; get the next song and stop playing at the at
|
;; this is pretty easy; get the next song and stop playing at the at
|
||||||
(let [[current-idx current-song] (find-where :playlist/currently-playing?? (:queue playlist))
|
(let [[current-idx current-song] (find-where :playlist/currently-playing? (:queue playlist))
|
||||||
[next-idx _] (find-where #(= (:playlist/order %) (inc (:playlist/order current-song))) (:queue playlist))]
|
[next-idx _] (find-where #(= (:playlist/order %) (inc (:playlist/order current-song))) (:queue playlist))]
|
||||||
(update playlist :queue
|
(update playlist :queue
|
||||||
(fn [queue]
|
(fn [queue]
|
||||||
(cond-> queue
|
(cond-> queue
|
||||||
current-idx (update current-idx dissoc :playlist/currently-playing??)
|
current-idx (update current-idx dissoc :playlist/currently-playing?)
|
||||||
next-idx (assoc-in [next-idx :playlist/currently-playing??] true))))))
|
next-idx (assoc-in [next-idx :playlist/currently-playing?] true))))))
|
||||||
|
|
||||||
(defmethod next-song :repeat-single [playlist] playlist)
|
(defmethod next-song :repeat-single [playlist] playlist)
|
||||||
|
|
||||||
(defmethod next-song :repeat-all
|
(defmethod next-song :repeat-all
|
||||||
[playlist]
|
[playlist]
|
||||||
(let [[current-idx current-song] (find-where :playlist/currently-playing?? (:queue playlist))
|
(let [[current-idx current-song] (find-where :playlist/currently-playing? (:queue playlist))
|
||||||
[next-idx _] (find-where #(= (:playlist/order %) (inc (:playlist/order current-song))) (:queue playlist))]
|
[next-idx _] (find-where #(= (:playlist/order %) (inc (:playlist/order current-song))) (:queue playlist))]
|
||||||
(-> (update-in playlist [:queue current-idx] dissoc :playlist/currently-playing??)
|
(-> (update-in playlist [:queue current-idx] dissoc :playlist/currently-playing?)
|
||||||
(update :queue
|
(update :queue
|
||||||
(fn [queue]
|
(fn [queue]
|
||||||
;; we need special treatment here if we're playing the last song and
|
;; we need special treatment here if we're playing the last song and
|
||||||
;; have a shuffled playlist because we need to re-shuffle
|
;; have a shuffled playlist because we need to re-shuffle
|
||||||
(if next-idx
|
(if next-idx
|
||||||
(assoc-in queue [next-idx :playlist/currently-playing??] true)
|
(assoc-in queue [next-idx :playlist/currently-playing?] true)
|
||||||
(case (:playback-mode playlist)
|
(case (:playback-mode playlist)
|
||||||
:linear (assoc-in queue [0 :playlist/currently-playing??] true)
|
:linear (assoc-in queue [0 :playlist/currently-playing?] true)
|
||||||
:shuffled (let [queue' (-shuffle-songs queue)
|
:shuffled (let [queue' (-shuffle-songs queue)
|
||||||
[next-idx _] (find-where #(= (:playlist/order %) 0) queue')]
|
[next-idx _] (find-where #(= (:playlist/order %) 0) queue')]
|
||||||
(assoc-in queue' [next-idx :playlist/currently-playing??] true)))))))))
|
(assoc-in queue' [next-idx :playlist/currently-playing?] true)))))))))
|
||||||
|
|
||||||
(defmulti previous-song "Goes back along the playback queue" :repeat-mode)
|
(defmulti previous-song "Goes back along the playback queue" :repeat-mode)
|
||||||
|
|
||||||
(defmethod previous-song :repeat-single [playlist] playlist)
|
(defmethod previous-song :repeat-single [playlist] playlist)
|
||||||
|
|
||||||
(defmethod previous-song :repeat-none [playlist]
|
(defmethod previous-song :repeat-none [playlist]
|
||||||
(let [[current-idx current-song] (find-where :playlist/currently-playing?? (:queue playlist))
|
(let [[current-idx current-song] (find-where :playlist/currently-playing? (:queue playlist))
|
||||||
[next-idx _] (find-where #(= (:playlist/order %) (dec (:playlist/order current-song))) (:queue playlist))]
|
[next-idx _] (find-where #(= (:playlist/order %) (dec (:playlist/order current-song))) (:queue playlist))]
|
||||||
(set-current-song playlist (or next-idx current-idx))))
|
(set-current-song playlist (or next-idx current-idx))))
|
||||||
|
|
||||||
(defmethod previous-song :repeat-all [playlist]
|
(defmethod previous-song :repeat-all [playlist]
|
||||||
(let [[_ current-song] (find-where :playlist/currently-playing?? (:queue playlist))
|
(let [[_ current-song] (find-where :playlist/currently-playing? (:queue playlist))
|
||||||
[next-idx _] (find-where #(= (:playlist/order %)
|
[next-idx _] (find-where #(= (:playlist/order %)
|
||||||
(rem (dec (:playlist/order current-song)) (count playlist)))
|
(rem (dec (:playlist/order current-song)) (count playlist)))
|
||||||
(:queue playlist))]
|
(:queue playlist))]
|
||||||
|
|
@ -133,7 +133,7 @@
|
||||||
(update playlist :queue conj (assoc song :playlist/order (inc highest-order)))))
|
(update playlist :queue conj (assoc song :playlist/order (inc highest-order)))))
|
||||||
|
|
||||||
(defn enqueue-next [playlist song]
|
(defn enqueue-next [playlist song]
|
||||||
(let [[_ current-song] (find-where :playlist/currently-playing?? (:queue playlist))]
|
(let [[_ current-song] (find-where :playlist/currently-playing? (:queue playlist))]
|
||||||
(update playlist :queue
|
(update playlist :queue
|
||||||
(fn [queue]
|
(fn [queue]
|
||||||
(-> (mapv #(if (> (:playlist/order %) (:playlist/order current-song)) (update % :playlist/order inc) %) queue)
|
(-> (mapv #(if (> (:playlist/order %) (:playlist/order current-song)) (update % :playlist/order inc) %) queue)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue