front:fix playlist page
This commit is contained in:
parent
25d6130cfa
commit
b46b2b3ab1
|
@ -2,7 +2,7 @@
|
||||||
import type { PlaylistTrack, Playlist, Track } from '~/types'
|
import type { PlaylistTrack, Playlist, Track } from '~/types'
|
||||||
|
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import { ref, computed } from 'vue'
|
import { ref, computed, watch } from 'vue'
|
||||||
import { useStore } from '~/store'
|
import { useStore } from '~/store'
|
||||||
|
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
@ -44,16 +44,12 @@ const store = useStore()
|
||||||
const edit = ref(props.defaultEdit)
|
const edit = ref(props.defaultEdit)
|
||||||
const playlist = ref<Playlist | null>(null)
|
const playlist = ref<Playlist | null>(null)
|
||||||
const playlistTracks = ref<PlaylistTrack[]>([])
|
const playlistTracks = ref<PlaylistTrack[]>([])
|
||||||
|
|
||||||
const showEmbedModal = ref(false)
|
const showEmbedModal = ref(false)
|
||||||
|
|
||||||
// TODO: Compute `tracks` with `track`. In the new types, `track` is just a string.
|
type FullPlaylistTrack = Omit<PlaylistTrack, 'track'> & { track: Track }
|
||||||
// We probably have to load each track before loading it into `tracks`.
|
const fullPlaylistTracks = ref<FullPlaylistTrack[]>([])
|
||||||
// Original line: const tracks = computed(() => playlistTracks.value.map(({ track }, index) => ({ ...track, position: index + 1 })))
|
|
||||||
const tracks = computed(() => playlistTracks.value.map(({ track }, index) => (
|
const tracks = computed(() => fullPlaylistTracks.value.map(({ track }, index) => ({ ...track as Track, position: index + 1 })))
|
||||||
// @i-would-expect-ts-to-error because this typecasting is evil
|
|
||||||
{ position: index + 1 } as Track
|
|
||||||
)))
|
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const labels = computed(() => ({
|
const labels = computed(() => ({
|
||||||
|
@ -71,7 +67,7 @@ const fetchData = async () => {
|
||||||
])
|
])
|
||||||
|
|
||||||
playlist.value = playlistResponse.data
|
playlist.value = playlistResponse.data
|
||||||
playlistTracks.value = tracksResponse.data.results
|
fullPlaylistTracks.value = tracksResponse.data.results
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
useErrorHandler(error as Error)
|
useErrorHandler(error as Error)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue