kopia lustrzana https://dev.funkwhale.audio/funkwhale/funkwhale
Fix shuffling
rodzic
f51007b807
commit
4376e40e26
|
@ -38,6 +38,7 @@ const {
|
||||||
queue,
|
queue,
|
||||||
currentIndex,
|
currentIndex,
|
||||||
currentTrack,
|
currentTrack,
|
||||||
|
isShuffled,
|
||||||
shuffle
|
shuffle
|
||||||
} = useQueue()
|
} = useQueue()
|
||||||
|
|
||||||
|
@ -277,7 +278,7 @@ const loopingTitle = computed(() => {
|
||||||
:aria-label="labels.shuffle"
|
:aria-label="labels.shuffle"
|
||||||
@click.prevent.stop="shuffle()"
|
@click.prevent.stop="shuffle()"
|
||||||
>
|
>
|
||||||
<i :class="['ui', 'random', {'disabled': queue.length === 0}, 'icon']" />
|
<i :class="['ui', 'random', { disabled: queue.length === 0, shuffling: isShuffled }, 'icon']" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="group">
|
<div class="group">
|
||||||
|
|
|
@ -159,8 +159,6 @@ export const useQueue = createGlobalState(() => {
|
||||||
if (index <= currentIndex.value) {
|
if (index <= currentIndex.value) {
|
||||||
currentIndex.value -= 1
|
currentIndex.value -= 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO (wvffle): Check if removing last element works well
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Play track
|
// Play track
|
||||||
|
@ -227,11 +225,19 @@ export const useQueue = createGlobalState(() => {
|
||||||
// Shuffle
|
// Shuffle
|
||||||
const shuffle = () => {
|
const shuffle = () => {
|
||||||
if (isShuffled.value) {
|
if (isShuffled.value) {
|
||||||
|
const id = shuffledIds.value[currentIndex.value]
|
||||||
shuffledIds.value.length = 0
|
shuffledIds.value.length = 0
|
||||||
|
|
||||||
|
// NOTE: This this looses the correct index when there are multiple tracks with the same id in the queue
|
||||||
|
// Since we shuffled the queue before, we probably do not even care for the correct index, just the order
|
||||||
|
currentIndex.value = tracks.value.indexOf(id)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
shuffledIds.value = shuffleArray(tracks.value)
|
const ids = [...tracks.value]
|
||||||
|
const [first] = ids.splice(currentIndex.value, 1)
|
||||||
|
shuffledIds.value = [first, ...shuffleArray(ids)]
|
||||||
|
currentIndex.value = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
const reshuffleUpcomingTracks = () => {
|
const reshuffleUpcomingTracks = () => {
|
||||||
|
|
|
@ -203,8 +203,8 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.shuffling .loader.inline {
|
.shuffling {
|
||||||
margin: 0;
|
color: var(--vibrant-color);
|
||||||
}
|
}
|
||||||
.control.circular.button {
|
.control.circular.button {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
|
Ładowanie…
Reference in New Issue