mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-05 02:34:56 +02:00
Add:Click timestamp in listening sessions table to open playback at timestamp #798, add confirm prompt
This commit is contained in:
parent
f1421f351b
commit
bcc2f847f9
4 changed files with 155 additions and 3 deletions
|
@ -39,7 +39,7 @@
|
|||
<td class="text-center">
|
||||
<p class="text-xs font-mono">{{ $elapsedPretty(session.timeListening) }}</p>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<td class="text-center hover:underline" @click.stop="clickCurrentTime(session)">
|
||||
<p class="text-xs font-mono">{{ $secondsToTimestamp(session.currentTime) }}</p>
|
||||
</td>
|
||||
<td class="text-center hidden sm:table-cell">
|
||||
|
@ -57,7 +57,7 @@
|
|||
</div>
|
||||
<p v-else class="text-white text-opacity-50">No sessions yet...</p>
|
||||
</div>
|
||||
|
||||
|
||||
<modals-listening-session-modal v-model="showSessionModal" :session="selectedSession" />
|
||||
</div>
|
||||
</template>
|
||||
|
@ -89,7 +89,8 @@ export default {
|
|||
total: 0,
|
||||
currentPage: 0,
|
||||
userFilter: null,
|
||||
selectedUser: ''
|
||||
selectedUser: '',
|
||||
processingGoToTimestamp: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -110,6 +111,41 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
async clickCurrentTime(session) {
|
||||
if (this.processingGoToTimestamp) return
|
||||
this.processingGoToTimestamp = true
|
||||
const libraryItem = await this.$axios.$get(`/api/items/${session.libraryItemId}`).catch((error) => {
|
||||
console.error('Failed to get library item', error)
|
||||
return null
|
||||
})
|
||||
|
||||
if (!libraryItem) {
|
||||
this.$toast.error('Failed to get library item')
|
||||
this.processingGoToTimestamp = false
|
||||
return
|
||||
}
|
||||
if (session.episodeId && !libraryItem.media.episodes.find((ep) => ep.id === session.episodeId)) {
|
||||
this.$toast.error('Failed to get podcast episode')
|
||||
this.processingGoToTimestamp = false
|
||||
return
|
||||
}
|
||||
|
||||
const payload = {
|
||||
message: `Start playback for "${session.displayTitle}" at ${this.$secondsToTimestamp(session.currentTime)}?`,
|
||||
callback: (confirmed) => {
|
||||
if (confirmed) {
|
||||
this.$eventBus.$emit('play-item', {
|
||||
libraryItemId: libraryItem.id,
|
||||
episodeId: session.episodeId || null,
|
||||
startTime: session.currentTime
|
||||
})
|
||||
}
|
||||
this.processingGoToTimestamp = false
|
||||
},
|
||||
type: 'yesNo'
|
||||
}
|
||||
this.$store.commit('globals/setConfirmPrompt', payload)
|
||||
},
|
||||
updateUserFilter() {
|
||||
this.loadSessions(0)
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue