Merge branch 'master' into HStep20/master

This commit is contained in:
advplyr
2023-05-20 10:18:16 -05:00
13 changed files with 142 additions and 96 deletions
-58
View File
@@ -37,7 +37,6 @@ export default {
data() {
return {
shelves: [],
isSettingsLoaded: false,
isFirstNetworkConnection: true,
lastServerFetch: 0,
lastServerFetchLibraryId: null,
@@ -258,11 +257,6 @@ export default {
return cat
})
// TODO: iOS has its own implementation of this. Android & iOS should be consistent here.
if (!this.isIos) {
this.openMediaPlayerWithMostRecentListening()
}
// Only add the local shelf with the same media type
const localShelves = localCategories.filter((cat) => cat.type === this.currentLibraryMediaType && !cat.localOnly)
this.shelves.push(...localShelves)
@@ -277,53 +271,6 @@ export default {
this.isLoading = false
},
async waitForSettings() {
// Wait up to 3 seconds
for (let i = 0; i < 6; i++) {
if (this.isSettingsLoaded) return true
await new Promise((resolve) => setTimeout(resolve, 500))
}
return false
},
async openMediaPlayerWithMostRecentListening() {
// If we don't already have a player open
// Try opening the first book from continue-listening without playing it
if (this.$store.state.playerLibraryItemId || !this.$store.state.isFirstAudioLoad) return
this.$store.commit('setIsFirstAudioLoad', false) // Only run this once on app launch
// Wait for settings to load to prevent race condition when setting playback speed.
if (!this.isSettingsLoaded) {
await this.waitForSettings()
}
const continueListeningShelf = this.shelves.find((cat) => cat.id === 'continue-listening')
const mostRecentEntity = continueListeningShelf?.entities?.find((li) => li.media?.audioTracks?.length || li.media?.numTracks)
if (mostRecentEntity) {
const playObject = {
libraryItemId: mostRecentEntity.id,
episodeId: mostRecentEntity.recentEpisode?.id || null,
paused: true
}
// Check if there is a local copy
if (mostRecentEntity.localLibraryItem) {
if (mostRecentEntity.recentEpisode) {
// Check if the podcast episode has a local copy
const localEpisode = mostRecentEntity.localLibraryItem.media.episodes.find((ep) => ep.serverEpisodeId === mostRecentEntity.recentEpisode.id)
if (localEpisode) {
playObject.libraryItemId = mostRecentEntity.localLibraryItem.id
playObject.episodeId = localEpisode.id
playObject.serverLibraryItemId = mostRecentEntity.id
playObject.serverEpisodeId = mostRecentEntity.recentEpisode.id
}
} else {
playObject.libraryItemId = mostRecentEntity.localLibraryItem.id
playObject.serverLibraryItemId = mostRecentEntity.id
}
}
this.$eventBus.$emit('play-item', playObject)
}
},
libraryChanged() {
if (this.currentLibraryId) {
console.log(`[categories] libraryChanged so fetching categories`)
@@ -370,16 +317,11 @@ export default {
}
})
},
settingsUpdated() {
this.isSettingsLoaded = true
},
initListeners() {
this.$eventBus.$on('library-changed', this.libraryChanged)
this.$eventBus.$on('user-settings', this.settingsUpdated)
},
removeListeners() {
this.$eventBus.$off('library-changed', this.libraryChanged)
this.$eventBus.$off('user-settings', this.settingsUpdated)
}
},
mounted() {
+18
View File
@@ -16,6 +16,14 @@
{{ title }}
</p>
<div v-if="episodeNumber || season || episodeType" class="flex py-2 items-center -mx-0.5">
<div v-if="episodeNumber" class="px-2 pt-px pb-0.5 mx-0.5 bg-primary bg-opacity-60 rounded-full text-xs font-light text-gray-200">Episode #{{ episodeNumber }}</div>
<div v-if="season" class="px-2 pt-px pb-0.5 mx-0.5 bg-primary bg-opacity-60 rounded-full text-xs font-light text-gray-200">Season #{{ season }}</div>
<div v-if="episodeType" class="px-2 pt-px pb-0.5 mx-0.5 bg-primary bg-opacity-60 rounded-full text-xs font-light text-gray-200 capitalize">
{{ episodeType }}
</div>
</div>
<!-- user progress card -->
<div v-if="progressPercent > 0" class="px-4 py-2 bg-primary text-sm font-semibold rounded-md text-gray-200 mt-4 relative" :class="resettingProgress ? 'opacity-25' : ''">
<p class="leading-6">Your Progress: {{ Math.round(progressPercent * 100) }}%</p>
@@ -160,6 +168,16 @@ export default {
description() {
return this.episode.description || ''
},
episodeNumber() {
return this.episode.episode
},
season() {
return this.episode.season
},
episodeType() {
if (this.episode.episodeType === 'full') return null // only show Trailer/Bonus
return this.episode.episodeType
},
duration() {
return this.$secondsToTimestamp(this.episode.duration)
},
+6
View File
@@ -86,6 +86,9 @@
</template>
</div>
<div v-if="podcastType" class="text-white text-opacity-60 uppercase text-sm">Type</div>
<div v-if="podcastType" class="text-sm capitalize">{{ podcastType }}</div>
<div v-if="series && series.length" class="text-white text-opacity-60 uppercase text-sm">Series</div>
<div v-if="series && series.length" class="truncate text-sm">
<template v-for="(series, index) in seriesList">
@@ -260,6 +263,9 @@ export default {
publishedYear() {
return this.mediaMetadata.publishedYear
},
podcastType() {
return this.mediaMetadata.type
},
podcastAuthor() {
if (!this.isPodcast) return null
return this.mediaMetadata.author || ''
+19 -7
View File
@@ -41,7 +41,16 @@
<template v-for="authorResult in authorResults">
<div :key="authorResult.id" class="w-full h-14 py-1">
<nuxt-link :to="`/bookshelf/library?filter=authors.${$encode(authorResult.id)}`">
<cards-author-search-card :key="authorResult.id" :author="authorResult" />
<cards-author-search-card :author="authorResult" />
</nuxt-link>
</div>
</template>
<p v-if="narratorResults.length" class="font-semibold text-sm mb-1 mt-2">Narrators</p>
<template v-for="narrator in narratorResults">
<div :key="narrator.name" class="w-full h-14 py-1">
<nuxt-link :to="`/bookshelf/library?filter=narrators.${$encode(narrator.name)}`">
<cards-narrator-search-card :narrator="narrator.name" />
</nuxt-link>
</div>
</template>
@@ -60,7 +69,8 @@ export default {
bookResults: [],
podcastResults: [],
seriesResults: [],
authorResults: []
authorResults: [],
narratorResults: []
}
},
computed: {
@@ -71,7 +81,7 @@ export default {
return this.$store.getters['libraries/getBookCoverAspectRatio']
},
totalResults() {
return this.bookResults.length + this.seriesResults.length + this.authorResults.length + this.podcastResults.length
return this.bookResults.length + this.seriesResults.length + this.authorResults.length + this.podcastResults.length + this.narratorResults.length
}
},
methods: {
@@ -86,6 +96,7 @@ export default {
this.podcastResults = []
this.seriesResults = []
this.authorResults = []
this.narratorResults = []
return
}
this.isFetching = true
@@ -101,10 +112,11 @@ export default {
this.isFetching = false
this.bookResults = results ? results.book || [] : []
this.podcastResults = results ? results.podcast || [] : []
this.seriesResults = results ? results.series || [] : []
this.authorResults = results ? results.authors || [] : []
this.bookResults = results?.book || []
this.podcastResults = results?.podcast || []
this.seriesResults = results?.series || []
this.authorResults = results?.authors || []
this.narratorResults = results?.narrators || []
},
updateSearch(val) {
clearTimeout(this.searchTimeout)