diff --git a/changes/changelog.d/262.enhancement b/changes/changelog.d/262.enhancement new file mode 100644 index 000000000..cad67e939 --- /dev/null +++ b/changes/changelog.d/262.enhancement @@ -0,0 +1 @@ +Added feedback on shuffle button (#262) diff --git a/front/src/components/audio/Player.vue b/front/src/components/audio/Player.vue index c475ec684..3c922e14a 100644 --- a/front/src/components/audio/Player.vue +++ b/front/src/components/audio/Player.vue @@ -113,7 +113,8 @@ :disabled="queue.tracks.length === 0" :title="$t('Shuffle your queue')" class="two wide column control"> - +
+
{ + self.$store.dispatch('queue/shuffle', () => { + self.isShuffling = false + self.$store.commit('ui/addMessage', { + content: self.$t('Queue shuffled!'), + date: new Date() + }) + }) + }, 100) + }, next () { let self = this this.$store.dispatch('queue/next').then(() => { @@ -402,5 +419,8 @@ export default { .ui.feed.icon { margin: 0; } +.shuffling.loader.inline { + margin: 0; +} diff --git a/front/src/store/queue.js b/front/src/store/queue.js index 23e074a80..2d6c667b2 100644 --- a/front/src/store/queue.js +++ b/front/src/store/queue.js @@ -72,16 +72,20 @@ export default { } }, - appendMany ({state, dispatch}, {tracks, index}) { + appendMany ({state, dispatch}, {tracks, index, callback}) { logger.default.info('Appending many tracks to the queue', tracks.map(e => { return e.title })) if (state.tracks.length === 0) { index = 0 } else { index = index || state.tracks.length } - tracks.forEach((t) => { - dispatch('append', {track: t, index: index, skipPlay: true}) + let total = tracks.length + tracks.forEach((t, i) => { + let p = dispatch('append', {track: t, index: index, skipPlay: true}) index += 1 + if (callback && i + 1 === total) { + p.then(callback) + } }) dispatch('resume') }, @@ -148,13 +152,17 @@ export default { // so we replay automatically on next track append commit('ended', true) }, - shuffle ({dispatch, commit, state}) { + shuffle ({dispatch, commit, state}, callback) { let toKeep = state.tracks.slice(0, state.currentIndex + 1) let toShuffle = state.tracks.slice(state.currentIndex + 1) let shuffled = toKeep.concat(_.shuffle(toShuffle)) commit('player/currentTime', 0, {root: true}) commit('tracks', []) - dispatch('appendMany', {tracks: shuffled}) + let params = {tracks: shuffled} + if (callback) { + params.callback = callback + } + dispatch('appendMany', params) } } }