refactor: moved all track preview logic in its component

This commit is contained in:
Roberto Tonino 2020-11-22 17:49:29 +01:00
parent 88da837663
commit fd17763ca3
9 changed files with 32 additions and 38 deletions

File diff suppressed because one or more lines are too long

View File

@ -10,16 +10,12 @@
</template> </template>
<script> <script>
import EventBus from '@/utils/EventBus' import { previewMouseEnter, previewMouseLeave } from '@components/globals/TheTrackPreview.vue'
export default { export default {
methods: { methods: {
previewMouseEnter(e) { previewMouseEnter,
EventBus.$emit('trackPreview:previewMouseEnter', e) previewMouseLeave
},
previewMouseLeave(e) {
EventBus.$emit('trackPreview:previewMouseLeave', e)
}
} }
} }
</script> </script>

View File

@ -5,10 +5,22 @@
</template> </template>
<script> <script>
import { mapGetters } from 'vuex'
import EventBus from '@/utils/EventBus' import EventBus from '@/utils/EventBus'
import { adjustVolume } from '@/utils/adjust-volume' import { adjustVolume } from '@/utils/adjust-volume'
import { mapGetters } from 'vuex'
export function playPausePreview(event) {
EventBus.$emit('trackPreview:playPausePreview', event)
}
export function previewMouseEnter(event) {
EventBus.$emit('trackPreview:previewMouseEnter', event)
}
export function previewMouseLeave(event) {
EventBus.$emit('trackPreview:previewMouseLeave', event)
}
export default { export default {
data: () => ({ data: () => ({

View File

@ -91,8 +91,8 @@ import { sendAddToQueue } from '@/utils/downloads'
import { convertDuration } from '@/utils/utils' import { convertDuration } from '@/utils/utils'
import { getChartsData } from '@/data/charts' import { getChartsData } from '@/data/charts'
import EventBus from '@/utils/EventBus'
import PreviewControls from '@components/globals/PreviewControls.vue' import PreviewControls from '@components/globals/PreviewControls.vue'
import { playPausePreview } from '@components/globals/TheTrackPreview.vue'
export default { export default {
components: { components: {
@ -137,9 +137,7 @@ export default {
}, },
methods: { methods: {
convertDuration, convertDuration,
playPausePreview(e) { playPausePreview,
EventBus.$emit('trackPreview:playPausePreview', e)
},
addToQueue(e) { addToQueue(e) {
e.stopPropagation() e.stopPropagation()
sendAddToQueue(e.currentTarget.dataset.link) sendAddToQueue(e.currentTarget.dataset.link)

View File

@ -188,9 +188,9 @@ import { convertDuration } from '@/utils/utils'
import { toast } from '@/utils/toasts' import { toast } from '@/utils/toasts'
import { getFavoritesData } from '@/data/favorites' import { getFavoritesData } from '@/data/favorites'
import EventBus from '@/utils/EventBus'
import PreviewControls from '@components/globals/PreviewControls.vue' import PreviewControls from '@components/globals/PreviewControls.vue'
import CoverContainer from '@components/globals/CoverContainer.vue' import CoverContainer from '@components/globals/CoverContainer.vue'
import { playPausePreview } from '@components/globals/TheTrackPreview.vue'
import { BaseTabs, BaseTab } from '@components/globals/BaseTabs' import { BaseTabs, BaseTab } from '@components/globals/BaseTabs'
export default { export default {
@ -244,9 +244,7 @@ export default {
}) })
}, },
methods: { methods: {
playPausePreview(e) { playPausePreview,
EventBus.$emit('trackPreview:playPausePreview', e)
},
convertDuration, convertDuration,
downloadAllOfType() { downloadAllOfType() {
try { try {

View File

@ -137,7 +137,6 @@
import { socket } from '@/utils/socket' import { socket } from '@/utils/socket'
import { convertDuration } from '@/utils/utils' import { convertDuration } from '@/utils/utils'
import { COUNTRIES } from '@/utils/countries' import { COUNTRIES } from '@/utils/countries'
import EventBus from '@/utils/EventBus'
import { sendAddToQueue } from '@/utils/downloads' import { sendAddToQueue } from '@/utils/downloads'
export default { export default {
@ -210,8 +209,6 @@ export default {
} }
}, },
mounted() { mounted() {
EventBus.$on('linkAnalyzerTab:reset', this.reset)
socket.on('analyze_track', this.showTrack) socket.on('analyze_track', this.showTrack)
socket.on('analyze_album', this.showAlbum) socket.on('analyze_album', this.showAlbum)
socket.on('analyze_notSupported', this.notSupported) socket.on('analyze_notSupported', this.notSupported)

View File

@ -42,7 +42,6 @@ import { BaseTabs, BaseTab } from '@components/globals/BaseTabs'
import { socket } from '@/utils/socket' import { socket } from '@/utils/socket'
import { sendAddToQueue } from '@/utils/downloads' import { sendAddToQueue } from '@/utils/downloads'
import { numberWithDots, convertDuration } from '@/utils/utils' import { numberWithDots, convertDuration } from '@/utils/utils'
import EventBus from '@/utils/EventBus'
import { formatSingleTrack, formatAlbums, formatArtist, formatPlaylist } from '@/data/search' import { formatSingleTrack, formatAlbums, formatArtist, formatPlaylist } from '@/data/search'
import { standardizeData } from '@/data/standardize' import { standardizeData } from '@/data/standardize'

View File

@ -155,7 +155,7 @@ import { isEmpty } from 'lodash-es'
import { socket } from '@/utils/socket' import { socket } from '@/utils/socket'
import Downloads from '@/utils/downloads' import Downloads from '@/utils/downloads'
import Utils from '@/utils/utils' import Utils from '@/utils/utils'
import EventBus from '@/utils/EventBus' import { playPausePreview } from '@components/globals/TheTrackPreview.vue'
export default { export default {
data() { data() {
@ -172,16 +172,12 @@ export default {
} }
}, },
mounted() { mounted() {
EventBus.$on('tracklistTab:selectRow', this.selectRow)
socket.on('show_album', this.showAlbum) socket.on('show_album', this.showAlbum)
socket.on('show_playlist', this.showPlaylist) socket.on('show_playlist', this.showPlaylist)
socket.on('show_spotifyplaylist', this.showSpotifyPlaylist) socket.on('show_spotifyplaylist', this.showSpotifyPlaylist)
}, },
methods: { methods: {
playPausePreview(e) { playPausePreview,
EventBus.$emit('trackPreview:playPausePreview', e)
},
reset() { reset() {
this.title = 'Loading...' this.title = 'Loading...'
this.image = '' this.image = ''

View File

@ -88,8 +88,8 @@
<script> <script>
import BaseLoadingPlaceholder from '@components/globals/BaseLoadingPlaceholder.vue' import BaseLoadingPlaceholder from '@components/globals/BaseLoadingPlaceholder.vue'
import PreviewControls from '@components/globals/PreviewControls.vue' import PreviewControls from '@components/globals/PreviewControls.vue'
import { playPausePreview } from '@components/globals/TheTrackPreview.vue'
import EventBus from '@/utils/EventBus'
import { convertDuration } from '@/utils/utils' import { convertDuration } from '@/utils/utils'
import { formatTitle } from '@/data/search' import { formatTitle } from '@/data/search'
@ -127,9 +127,7 @@ export default {
methods: { methods: {
convertDuration, convertDuration,
formatTitle, formatTitle,
playPausePreview(e) { playPausePreview
EventBus.$emit('trackPreview:playPausePreview', e)
}
} }
} }
</script> </script>