Skip to content

Commit

Permalink
move play queue server side
Browse files Browse the repository at this point in the history
  • Loading branch information
tamland committed Oct 21, 2024
1 parent f5709b9 commit b94c447
Show file tree
Hide file tree
Showing 6 changed files with 357 additions and 278 deletions.
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ watch(
return Promise.all([
useFavouriteStore().load(),
usePlaylistStore().load(),
playerStore.dispatch('player/loadQueue'),
])
}
})
Expand Down
5 changes: 1 addition & 4 deletions src/player/Player.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div :class="{'visible': visible}" class="player elevated d-flex">
<div :class="{'visible': track}" class="player elevated d-flex">
<div class="flex-fill">
<ProgressBar v-if="track" style="margin-bottom: -5px; margin-top: -9px" />

Expand Down Expand Up @@ -145,9 +145,6 @@
}
},
computed: {
visible() {
return this.$store.state.player.queue.length > 0
},
isPlaying() {
return this.$store.state.player.isPlaying
},
Expand Down
69 changes: 37 additions & 32 deletions src/player/Queue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,40 @@
</b-button>
</div>
</div>
<BaseTable v-if="tracks.length > 0">
<BaseTableHead>
<th class="text-left d-none d-lg-table-cell">
Artist
</th>
<th class="text-left d-none d-md-table-cell">
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" :value="item.track" />
<CellTitle :track="item" />
<CellArtist :track="item" />
<CellAlbum :track="item" />
<CellDuration :track="item" />
<CellActions :track="item">
<b-dropdown-divider />
<ContextMenuItem icon="x" variant="danger" @click="remove(index)">
Remove
</ContextMenuItem>
</CellActions>
</tr>
</tbody>
</BaseTable>
<EmptyIndicator v-else />
<ContentLoader v-slot :loading="loading">
<BaseTable v-if="tracks.length > 0">
<BaseTableHead>
<th class="text-left d-none d-lg-table-cell">
Artist
</th>
<th class="text-left d-none d-md-table-cell">
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" :value="item.track" />
<CellTitle :track="item" />
<CellArtist :track="item" />
<CellAlbum :track="item" />
<CellDuration :track="item" />
<CellActions :track="item">
<b-dropdown-divider />
<ContextMenuItem icon="x" variant="danger" @click="remove(index)">
Remove
</ContextMenuItem>
</CellActions>
</tr>
</tbody>
</BaseTable>
<EmptyIndicator v-else />
</ContentLoader>
</div>
</template>
<script lang="ts">
Expand All @@ -70,6 +72,9 @@
BaseTable,
},
computed: {
loading() {
return this.$store.state.player.queue === null
},
isPlaying() {
return this.$store.getters['player/isPlaying']
},
Expand Down
Loading

0 comments on commit b94c447

Please sign in to comment.