Android & iOS only open most recent session on first load

This commit is contained in:
advplyr 2023-02-17 17:14:49 -06:00
parent aab44d8cee
commit d899fd4d89
3 changed files with 23 additions and 6 deletions

View file

@ -43,6 +43,9 @@ export default {
bookmarks() { bookmarks() {
if (!this.serverLibraryItemId) return [] if (!this.serverLibraryItemId) return []
return this.$store.getters['user/getUserBookmarksForItem'](this.serverLibraryItemId) return this.$store.getters['user/getUserBookmarksForItem'](this.serverLibraryItemId)
},
isIos() {
return this.$platform === 'ios'
} }
}, },
methods: { methods: {
@ -266,12 +269,17 @@ export default {
onReady() { onReady() {
// The UI is reporting elsewhere we are ready // The UI is reporting elsewhere we are ready
this.isReady = true this.isReady = true
// TODO: iOS opens last active playback session on app launch. Should be consistent with Android
if (this.isIos) {
this.notifyOnReady() this.notifyOnReady()
}
}, },
notifyOnReady() { notifyOnReady() {
// If settings aren't loaded yet, native player will receive incorrect settings // If settings aren't loaded yet, native player will receive incorrect settings
console.log('Notify on ready... settingsLoaded:', this.settingsLoaded, 'isReady:', this.isReady) 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() AbsAudioPlayer.onReady()
} }
} }

View file

@ -39,7 +39,6 @@ export default {
shelves: [], shelves: [],
loading: false, loading: false,
isFirstNetworkConnection: true, isFirstNetworkConnection: true,
isFirstAutoOpenPlayer: true,
lastServerFetch: 0, lastServerFetch: 0,
lastServerFetchLibraryId: null, lastServerFetchLibraryId: null,
lastLocalFetch: 0, lastLocalFetch: 0,
@ -78,6 +77,9 @@ export default {
networkConnected() { networkConnected() {
return this.$store.state.networkConnected return this.$store.state.networkConnected
}, },
isIos() {
return this.$platform === 'ios'
},
currentLibraryName() { currentLibraryName() {
return this.$store.getters['libraries/getCurrentLibraryName'] return this.$store.getters['libraries/getCurrentLibraryName']
}, },
@ -248,7 +250,10 @@ export default {
return cat return cat
}) })
// TODO: iOS has its own implementation of this. Android & iOS should be consistent here.
if (!this.isIos) {
this.openMediaPlayerWithMostRecentListening() this.openMediaPlayerWithMostRecentListening()
}
// Only add the local shelf with the same media type // Only add the local shelf with the same media type
const localShelves = localCategories.filter((cat) => cat.type === this.currentLibraryMediaType && !cat.localOnly) const localShelves = localCategories.filter((cat) => cat.type === this.currentLibraryMediaType && !cat.localOnly)
@ -267,8 +272,8 @@ export default {
openMediaPlayerWithMostRecentListening() { openMediaPlayerWithMostRecentListening() {
// If we don't already have a player open // If we don't already have a player open
// Try opening the first book from continue-listening without playing it // Try opening the first book from continue-listening without playing it
if (this.$store.state.playerLibraryItemId || !this.isFirstAutoOpenPlayer) return if (this.$store.state.playerLibraryItemId || !this.$store.state.isFirstAudioLoad) return
this.isFirstAutoOpenPlayer = false // Only run this once, not on every library change this.$store.commit('setIsFirstAudioLoad', false) // Only run this once on app launch
const continueListeningShelf = this.shelves.find((cat) => cat.id === 'continue-listening') const continueListeningShelf = this.shelves.find((cat) => cat.id === 'continue-listening')
const mostRecentEntity = continueListeningShelf?.entities?.[0] const mostRecentEntity = continueListeningShelf?.entities?.[0]

View file

@ -15,6 +15,7 @@ export const state = () => ({
networkConnectionType: null, networkConnectionType: null,
isNetworkUnmetered: true, isNetworkUnmetered: true,
isFirstLoad: true, isFirstLoad: true,
isFirstAudioLoad: true,
hasStoragePermission: false, hasStoragePermission: false,
selectedLibraryItem: null, selectedLibraryItem: null,
showReader: false, showReader: false,
@ -120,6 +121,9 @@ export const mutations = {
setIsFirstLoad(state, val) { setIsFirstLoad(state, val) {
state.isFirstLoad = val state.isFirstLoad = val
}, },
setIsFirstAudioLoad(state, val) {
state.isFirstAudioLoad = val
},
setSocketConnected(state, val) { setSocketConnected(state, val) {
state.socketConnected = val state.socketConnected = val
}, },