mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-14 16:25:03 -05:00
2 lines
3.5 KiB
JavaScript
2 lines
3.5 KiB
JavaScript
import{C as S}from"./ContentWithHeading.js";import{L as T,M as E}from"./ModalDialogTrackSpotify.js";import{M as v}from"./ModalDialogPlaylistSpotify.js";import{S as g}from"./spotify-web-api.js";import{_ as V,s as y,e as A,r as n,o as _,c as k,d as r,w as c,a as l,t as f,F as L,f as M,g as u,h as z,b as B,k as N}from"./index.js";import{G as D}from"./vue-eternal-loading.js";const h=50,d={load(t){const s=new g;return s.setAccessToken(y.state.spotify.webapi_token),Promise.all([s.getPlaylist(t.params.id),s.getPlaylistTracks(t.params.id,{limit:h,offset:0,market:y.state.spotify.webapi_country})])},set(t,s){t.playlist=s[0],t.tracks=[],t.total=0,t.offset=0,t.append_tracks(s[1])}},F={name:"PagePlaylistTracksSpotify",components:{ContentWithHeading:S,ListItemTrackSpotify:T,ModalDialogPlaylistSpotify:v,ModalDialogTrackSpotify:E,VueEternalLoading:D},beforeRouteEnter(t,s,o){d.load(t).then(a=>{o(e=>d.set(e,a))})},beforeRouteUpdate(t,s,o){const a=this;d.load(t).then(e=>{d.set(a,e),o()})},data(){return{playlist:{tracks:{}},tracks:[],total:0,offset:0,show_track_details_modal:!1,selected_track:{},show_playlist_details_modal:!1}},methods:{load_next({loaded:t}){const s=new g;s.setAccessToken(this.$store.state.spotify.webapi_token),s.getPlaylistTracks(this.playlist.id,{limit:h,offset:this.offset,market:y.state.spotify.webapi_country}).then(o=>{this.append_tracks(o),t(o.items.length,h)})},append_tracks(t){let s=Math.max(-1,...this.tracks.map(o=>o.position).filter(o=>o));t.items.forEach(o=>{const{track:a}=o;a&&(a.is_playable&&(a.position=++s),this.tracks.push(a))}),this.total=t.total,this.offset+=t.limit},play(){this.show_details_modal=!1,A.player_play_uri(this.playlist.uri,!0)},open_track_dialog(t){this.selected_track=t,this.show_track_details_modal=!0}}},G=["textContent"],I={class:"buttons is-centered"},R=["textContent"],W=["textContent"],j=["onClick"];function H(t,s,o,a,e,p){const m=n("mdicon"),w=n("list-item-track-spotify"),b=n("VueEternalLoading"),C=n("modal-dialog-track-spotify"),x=n("modal-dialog-playlist-spotify"),P=n("content-with-heading");return _(),k("div",null,[r(P,null,{"heading-left":c(()=>[l("div",{class:"title is-4",textContent:f(e.playlist.name)},null,8,G)]),"heading-right":c(()=>[l("div",I,[l("a",{class:"button is-small is-light is-rounded",onClick:s[0]||(s[0]=i=>e.show_playlist_details_modal=!0)},[r(m,{class:"icon",name:"dots-horizontal",size:"16"})]),l("a",{class:"button is-small is-dark is-rounded",onClick:s[1]||(s[1]=(...i)=>p.play&&p.play(...i))},[r(m,{class:"icon",name:"shuffle",size:"16"}),l("span",{textContent:f(t.$t("page.spotify.playlist.shuffle"))},null,8,R)])])]),content:c(()=>[l("p",{class:"heading has-text-centered-mobile",textContent:f(t.$t("page.spotify.playlist.count",{count:e.playlist.tracks.total}))},null,8,W),(_(!0),k(L,null,M(e.tracks,i=>(_(),u(w,{key:i.id,track:i,position:i.position,context_uri:e.playlist.uri},{actions:c(()=>[l("a",{onClick:z(O=>p.open_track_dialog(i),["prevent","stop"])},[r(m,{class:"icon has-text-dark",name:"dots-vertical",size:"16"})],8,j)]),_:2},1032,["track","position","context_uri"]))),128)),e.offset<e.total?(_(),u(b,{key:0,load:p.load_next},{"no-more":c(()=>[B(" . ")]),_:1},8,["load"])):N("",!0),r(C,{show:e.show_track_details_modal,track:e.selected_track,album:e.selected_track.album,onClose:s[2]||(s[2]=i=>e.show_track_details_modal=!1)},null,8,["show","track","album"]),r(x,{show:e.show_playlist_details_modal,playlist:e.playlist,onClose:s[3]||(s[3]=i=>e.show_playlist_details_modal=!1)},null,8,["show","playlist"])]),_:1})])}const X=V(F,[["render",H]]);export{X as default};
|