mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-07-28 14:44:30 +02:00
Android & iOS only open most recent session on first load
This commit is contained in:
parent
aab44d8cee
commit
d899fd4d89
3 changed files with 23 additions and 6 deletions
|
@ -43,6 +43,9 @@ export default {
|
|||
bookmarks() {
|
||||
if (!this.serverLibraryItemId) return []
|
||||
return this.$store.getters['user/getUserBookmarksForItem'](this.serverLibraryItemId)
|
||||
},
|
||||
isIos() {
|
||||
return this.$platform === 'ios'
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -266,12 +269,17 @@ export default {
|
|||
onReady() {
|
||||
// The UI is reporting elsewhere we are ready
|
||||
this.isReady = true
|
||||
this.notifyOnReady()
|
||||
|
||||
// TODO: iOS opens last active playback session on app launch. Should be consistent with Android
|
||||
if (this.isIos) {
|
||||
this.notifyOnReady()
|
||||
}
|
||||
},
|
||||
notifyOnReady() {
|
||||
// If settings aren't loaded yet, native player will receive incorrect settings
|
||||
console.log('Notify on ready... settingsLoaded:', this.settingsLoaded, 'isReady:', this.isReady)
|
||||
if (this.settingsLoaded && this.isReady) {
|
||||
if (this.settingsLoaded && this.isReady && this.$store.state.isFirstAudioLoad) {
|
||||
this.$store.commit('setIsFirstAudioLoad', false) // Only run this once on app launch
|
||||
AbsAudioPlayer.onReady()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ export default {
|
|||
shelves: [],
|
||||
loading: false,
|
||||
isFirstNetworkConnection: true,
|
||||
isFirstAutoOpenPlayer: true,
|
||||
lastServerFetch: 0,
|
||||
lastServerFetchLibraryId: null,
|
||||
lastLocalFetch: 0,
|
||||
|
@ -78,6 +77,9 @@ export default {
|
|||
networkConnected() {
|
||||
return this.$store.state.networkConnected
|
||||
},
|
||||
isIos() {
|
||||
return this.$platform === 'ios'
|
||||
},
|
||||
currentLibraryName() {
|
||||
return this.$store.getters['libraries/getCurrentLibraryName']
|
||||
},
|
||||
|
@ -248,7 +250,10 @@ export default {
|
|||
return cat
|
||||
})
|
||||
|
||||
this.openMediaPlayerWithMostRecentListening()
|
||||
// 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)
|
||||
|
@ -267,8 +272,8 @@ export default {
|
|||
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.isFirstAutoOpenPlayer) return
|
||||
this.isFirstAutoOpenPlayer = false // Only run this once, not on every library change
|
||||
if (this.$store.state.playerLibraryItemId || !this.$store.state.isFirstAudioLoad) return
|
||||
this.$store.commit('setIsFirstAudioLoad', false) // Only run this once on app launch
|
||||
|
||||
const continueListeningShelf = this.shelves.find((cat) => cat.id === 'continue-listening')
|
||||
const mostRecentEntity = continueListeningShelf?.entities?.[0]
|
||||
|
|
|
@ -15,6 +15,7 @@ export const state = () => ({
|
|||
networkConnectionType: null,
|
||||
isNetworkUnmetered: true,
|
||||
isFirstLoad: true,
|
||||
isFirstAudioLoad: true,
|
||||
hasStoragePermission: false,
|
||||
selectedLibraryItem: null,
|
||||
showReader: false,
|
||||
|
@ -120,6 +121,9 @@ export const mutations = {
|
|||
setIsFirstLoad(state, val) {
|
||||
state.isFirstLoad = val
|
||||
},
|
||||
setIsFirstAudioLoad(state, val) {
|
||||
state.isFirstAudioLoad = val
|
||||
},
|
||||
setSocketConnected(state, val) {
|
||||
state.socketConnected = val
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue