diff --git a/src/cljs/airsonic_ui/audio/playlist.cljs b/src/cljs/airsonic_ui/audio/playlist.cljs index bf7e9ba..0cc374a 100644 --- a/src/cljs/airsonic_ui/audio/playlist.cljs +++ b/src/cljs/airsonic_ui/audio/playlist.cljs @@ -27,7 +27,7 @@ "This function is used if we switch from linear to shuffled; it allows us to restore the order of the queue when it was created." [items] - (->> (sort-by (comp meta :playlist/linear-order) items) + (->> (sort-by (comp :playlist/linear-order meta) items) (map-indexed (fn [idx item] (vary-meta item assoc :playlist/linear-order idx))))) @@ -85,7 +85,8 @@ queue-fn (case playback-mode :shuffled shuffled-queue :linear linear-queue) - next-playlist (update playlist :items (comp queue-fn vals)) + next-playlist (-> (assoc playlist :playback-mode playback-mode) + (update :items (comp queue-fn vals))) next-idx (first (keep (fn [[idx song]] (when (= song current-song) idx)) diff --git a/src/cljs/airsonic_ui/components/current_queue/views.cljs b/src/cljs/airsonic_ui/components/current_queue/views.cljs index 7bc4ab6..1744561 100644 --- a/src/cljs/airsonic_ui/components/current_queue/views.cljs +++ b/src/cljs/airsonic_ui/components/current_queue/views.cljs @@ -51,6 +51,7 @@ [:td.sort-handle.is-narrow [:> SortHandle]] [:td.song-artist [artist-link song]] [:td.song-title (:title song)] + [:td.meta>code (str (meta song))] [:td.song-duration (helpers/format-duration (:duration song) :brief? true)] [:td.song-actions.is-narrow [song-actions]]]) diff --git a/test/cljs/airsonic_ui/audio/playlist_test.cljs b/test/cljs/airsonic_ui/audio/playlist_test.cljs index c0f6921..b9d4a41 100644 --- a/test/cljs/airsonic_ui/audio/playlist_test.cljs +++ b/test/cljs/airsonic_ui/audio/playlist_test.cljs @@ -62,6 +62,9 @@ (let [queue (song-queue 10) linear (playlist/->playlist queue :playback-mode :linear :repeat-mode :repeat-none) shuffled (playlist/set-playback-mode linear :shuffled)] + (testing "should indicate the new playback mode" + (is (= :linear (:playback-mode linear))) + (is (= :shuffled (:playback-mode shuffled)))) (testing "should re-order the tracks" (is (not= (:items shuffled) (:items linear)))) (testing "should not change the currently playing track" @@ -72,10 +75,16 @@ (let [queue (song-queue 10) shuffled (playlist/->playlist queue :playback-mode :shuffled :repeat-mode :repeat-none) linear (playlist/set-playback-mode shuffled :linear)] + (testing "should indicate the new playback mode" + (is (= :linear (:playback-mode linear))) + (is (= :shuffled (:playback-mode shuffled)))) (testing "should set the correct order for tracks" - (is (every? #(apply same-song? %) (interleave queue (vals (:items linear))))) - (is (< (:playlist/linear-order (meta (first (vals (:items linear))))) - (:playlist/linear-order (meta (last (vals (:items linear)))))))) + (let [linear-order (comp :playlist/linear-order meta)] + (is (every? #(apply same-song? %) (interleave queue (vals (:items linear))))) + ;; every song should have a smaller order than its successor + (is (->> (map linear-order (vals (:items linear))) + (partition 2 1) + (every? (fn [[a b]] (< a b))))))) (testing "should not change the currently playing track" (is (same-song? (playlist/current-song linear) (playlist/current-song shuffled)))) (testing "should not change the repeat mode"