highlight playing track in queue based on queue index instead of track id
fixes #16
This commit is contained in:
		
							parent
							
								
									9ab8c444ef
								
							
						
					
					
						commit
						727be5b16b
					
				| @ -8,34 +8,89 @@ | |||||||
|         Clear |         Clear | ||||||
|       </b-button> |       </b-button> | ||||||
|     </div> |     </div> | ||||||
|     <TrackList :tracks="tracks"> |     <BaseTable> | ||||||
|       <template #context-menu="{index}"> |       <BaseTableHead> | ||||||
|         <b-dropdown-item-button @click="remove(index)"> |         <th class="text-left d-none d-lg-table-cell"> | ||||||
|           Remove |           Artist | ||||||
|         </b-dropdown-item-button> |         </th> | ||||||
|       </template> |         <th class="text-left d-none d-md-table-cell"> | ||||||
|     </TrackList> |           Album | ||||||
|  |         </th> | ||||||
|  |         <th class="text-right d-none d-md-table-cell"> | ||||||
|  |           Duration | ||||||
|  |         </th> | ||||||
|  |       </BaseTableHead> | ||||||
|  |       <tbody> | ||||||
|  |         <tr v-for="(item, index) in tracks" :key="index" | ||||||
|  |             :class="{'active': index === queueIndex}" | ||||||
|  |             :draggable="true" @dragstart="dragstart(item.id, $event)" | ||||||
|  |             @click="play(index)"> | ||||||
|  |           <CellTrackNumber :active="index === queueIndex && isPlaying" :track="item" /> | ||||||
|  |           <CellTitle :track="item" /> | ||||||
|  |           <CellArtist :track="item" /> | ||||||
|  |           <CellAlbum :track="item" /> | ||||||
|  |           <CellDuration :track="item" /> | ||||||
|  |           <CellActions :track="item"> | ||||||
|  |             <b-dropdown-item-button @click="remove(index)"> | ||||||
|  |               Remove | ||||||
|  |             </b-dropdown-item-button> | ||||||
|  |           </CellActions> | ||||||
|  |         </tr> | ||||||
|  |       </tbody> | ||||||
|  |     </BaseTable> | ||||||
|   </div> |   </div> | ||||||
| </template> | </template> | ||||||
| <script lang="ts"> | <script lang="ts"> | ||||||
|   import Vue from 'vue' |   import Vue from 'vue' | ||||||
|   import { mapState, mapMutations } from 'vuex' |   import { mapState, mapMutations, mapGetters } from 'vuex' | ||||||
|   import TrackList from '@/library/track/TrackList.vue' |   import TrackList from '@/library/track/TrackList.vue' | ||||||
|  |   import BaseTable from '@/library/track/BaseTable.vue' | ||||||
|  |   import BaseTableHead from '@/library/track/BaseTableHead.vue' | ||||||
|  |   import CellTrackNumber from '@/library/track/CellTrackNumber.vue' | ||||||
|  |   import CellDuration from '@/library/track/CellDuration.vue' | ||||||
|  |   import CellAlbum from '@/library/track/CellAlbum.vue' | ||||||
|  |   import CellArtist from '@/library/track/CellArtist.vue' | ||||||
|  |   import CellTitle from '@/library/track/CellTitle.vue' | ||||||
|  |   import CellActions from '@/library/track/CellActions.vue' | ||||||
| 
 | 
 | ||||||
|   export default Vue.extend({ |   export default Vue.extend({ | ||||||
|     components: { |     components: { | ||||||
|  |       CellActions, | ||||||
|  |       CellTitle, | ||||||
|  |       CellArtist, | ||||||
|  |       CellAlbum, | ||||||
|  |       CellDuration, | ||||||
|  |       CellTrackNumber, | ||||||
|  |       BaseTableHead, | ||||||
|  |       BaseTable, | ||||||
|       TrackList, |       TrackList, | ||||||
|     }, |     }, | ||||||
|     computed: { |     computed: { | ||||||
|       ...mapState('player', { |       ...mapState('player', { | ||||||
|         tracks: (state: any) => state.queue, |         tracks: 'queue', | ||||||
|       }) |         queueIndex: 'queueIndex', | ||||||
|  |       }), | ||||||
|  |       ...mapGetters('player', { | ||||||
|  |         isPlaying: 'isPlaying', | ||||||
|  |       }), | ||||||
|     }, |     }, | ||||||
|     methods: { |     methods: { | ||||||
|       ...mapMutations('player', { |       ...mapMutations('player', { | ||||||
|         remove: 'removeFromQueue', |         remove: 'removeFromQueue', | ||||||
|         clear: 'clearQueue', |         clear: 'clearQueue', | ||||||
|       }), |       }), | ||||||
|  |       play(index: number) { | ||||||
|  |         if (index === this.queueIndex) { | ||||||
|  |           return this.$store.dispatch('player/playPause') | ||||||
|  |         } | ||||||
|  |         return this.$store.dispatch('player/playTrackList', { | ||||||
|  |           index, | ||||||
|  |           tracks: this.tracks, | ||||||
|  |         }) | ||||||
|  |       }, | ||||||
|  |       dragstart(id: string, event: any) { | ||||||
|  |         event.dataTransfer.setData('id', id) | ||||||
|  |       }, | ||||||
|     } |     } | ||||||
|   }) |   }) | ||||||
| </script> | </script> | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user