kopia lustrzana https://dev.funkwhale.audio/funkwhale/funkwhale
				
				
				
			Fix #97: Queue shuffle now apply only to tracks after the current one
							rodzic
							
								
									ae65190364
								
							
						
					
					
						commit
						6a30e59aa2
					
				| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
Queue shuffle now apply only to tracks after the current one (#97)
 | 
			
		||||
| 
						 | 
				
			
			@ -41,7 +41,6 @@ export default {
 | 
			
		|||
        state.currentIndex += 1
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  },
 | 
			
		||||
  getters: {
 | 
			
		||||
    currentTrack: state => {
 | 
			
		||||
| 
						 | 
				
			
			@ -141,7 +140,9 @@ export default {
 | 
			
		|||
      commit('ended', true)
 | 
			
		||||
    },
 | 
			
		||||
    shuffle ({dispatch, commit, state}) {
 | 
			
		||||
      let shuffled = _.shuffle(state.tracks)
 | 
			
		||||
      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})
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -316,18 +316,18 @@ describe('store/queue', () => {
 | 
			
		|||
    })
 | 
			
		||||
    it('shuffle', (done) => {
 | 
			
		||||
      let _shuffle = sandbox.stub(_, 'shuffle')
 | 
			
		||||
      let tracks = [1, 2, 3]
 | 
			
		||||
      let shuffledTracks = [2, 3, 1]
 | 
			
		||||
      let tracks = ['a', 'b', 'c', 'd', 'e']
 | 
			
		||||
      let shuffledTracks = ['e', 'd', 'c']
 | 
			
		||||
      _shuffle.returns(shuffledTracks)
 | 
			
		||||
      testAction({
 | 
			
		||||
        action: store.actions.shuffle,
 | 
			
		||||
        params: {state: {tracks: tracks}},
 | 
			
		||||
        params: {state: {currentIndex: 1, tracks: tracks}},
 | 
			
		||||
        expectedMutations: [
 | 
			
		||||
          { type: 'player/currentTime', payload: 0 , options: {root: true}},
 | 
			
		||||
          { type: 'tracks', payload: [] }
 | 
			
		||||
        ],
 | 
			
		||||
        expectedActions: [
 | 
			
		||||
          { type: 'appendMany', payload: {tracks: shuffledTracks} }
 | 
			
		||||
          { type: 'appendMany', payload: {tracks: ['a', 'b'].concat(shuffledTracks)} }
 | 
			
		||||
        ]
 | 
			
		||||
      }, done)
 | 
			
		||||
    })
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue