2018-08-11 07:47:10 +02:00
|
|
|
<template>
|
2022-02-19 06:18:01 +01:00
|
|
|
<div class="fd-page-with-tabs">
|
2022-02-19 06:39:14 +01:00
|
|
|
<tabs-music />
|
2018-08-11 07:47:10 +02:00
|
|
|
<content-with-heading>
|
2022-02-19 06:39:14 +01:00
|
|
|
<template #heading-left>
|
2023-11-21 15:25:27 +01:00
|
|
|
<p class="title is-4" v-text="$t('page.spotify.music.new-releases')" />
|
2018-08-11 07:47:10 +02:00
|
|
|
</template>
|
2022-02-19 06:39:14 +01:00
|
|
|
<template #content>
|
2024-03-25 21:54:01 +01:00
|
|
|
<list-item-album-spotify :items="new_releases" />
|
2018-08-11 07:47:10 +02:00
|
|
|
</template>
|
|
|
|
</content-with-heading>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-07-18 15:19:24 +02:00
|
|
|
import * as types from '@/store/mutation_types'
|
2022-02-19 06:18:01 +01:00
|
|
|
import ContentWithHeading from '@/templates/ContentWithHeading.vue'
|
2023-07-18 15:19:24 +02:00
|
|
|
import ListItemAlbumSpotify from '@/components/ListItemAlbumSpotify.vue'
|
2018-08-11 07:47:10 +02:00
|
|
|
import SpotifyWebApi from 'spotify-web-api-js'
|
2023-07-18 15:19:24 +02:00
|
|
|
import TabsMusic from '@/components/TabsMusic.vue'
|
2024-02-28 15:24:55 +01:00
|
|
|
import store from '@/store'
|
2018-08-11 07:47:10 +02:00
|
|
|
|
2022-02-19 06:18:01 +01:00
|
|
|
const dataObject = {
|
2023-06-07 21:25:54 +02:00
|
|
|
load(to) {
|
2018-08-11 07:47:10 +02:00
|
|
|
if (store.state.spotify_new_releases.length > 0) {
|
|
|
|
return Promise.resolve()
|
|
|
|
}
|
|
|
|
|
|
|
|
const spotifyApi = new SpotifyWebApi()
|
|
|
|
spotifyApi.setAccessToken(store.state.spotify.webapi_token)
|
2022-02-19 06:39:14 +01:00
|
|
|
return spotifyApi.getNewReleases({
|
|
|
|
country: store.state.spotify.webapi_country,
|
|
|
|
limit: 50
|
|
|
|
})
|
2018-08-11 07:47:10 +02:00
|
|
|
},
|
|
|
|
|
2023-06-07 21:25:54 +02:00
|
|
|
set(vm, response) {
|
2018-08-11 07:47:10 +02:00
|
|
|
if (response) {
|
|
|
|
store.commit(types.SPOTIFY_NEW_RELEASES, response.albums.items)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
2023-11-21 15:25:27 +01:00
|
|
|
name: 'PageMusicSpotifyNewReleases',
|
2022-02-19 06:39:14 +01:00
|
|
|
components: {
|
|
|
|
ContentWithHeading,
|
2023-07-18 15:19:24 +02:00
|
|
|
ListItemAlbumSpotify,
|
2023-07-12 21:30:52 +02:00
|
|
|
TabsMusic
|
2022-02-19 06:39:14 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
beforeRouteEnter(to, from, next) {
|
|
|
|
dataObject.load(to).then((response) => {
|
|
|
|
next((vm) => dataObject.set(vm, response))
|
|
|
|
})
|
|
|
|
},
|
|
|
|
beforeRouteUpdate(to, from, next) {
|
|
|
|
const vm = this
|
|
|
|
dataObject.load(to).then((response) => {
|
|
|
|
dataObject.set(vm, response)
|
|
|
|
next()
|
|
|
|
})
|
|
|
|
},
|
2018-12-17 11:52:09 +01:00
|
|
|
|
2018-08-11 07:47:10 +02:00
|
|
|
computed: {
|
2024-03-24 18:05:29 +01:00
|
|
|
new_releases() {
|
|
|
|
return this.$store.state.spotify_new_releases
|
2018-08-11 07:47:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
<style></style>
|