diff --git a/components/app/AudioPlayer.vue b/components/app/AudioPlayer.vue index 86599de1..fc126021 100644 --- a/components/app/AudioPlayer.vue +++ b/components/app/AudioPlayer.vue @@ -450,7 +450,6 @@ export default { this.$emit('showSleepTimer') }, async setPlaybackSpeed(speed) { - await this.$hapticsImpact() console.log(`[AudioPlayer] Set Playback Rate: ${speed}`) this.currentPlaybackRate = speed this.updateTimestamp() diff --git a/pages/bookshelf/index.vue b/pages/bookshelf/index.vue index 0ea6729e..01655d0b 100644 --- a/pages/bookshelf/index.vue +++ b/pages/bookshelf/index.vue @@ -37,6 +37,7 @@ export default { data() { return { shelves: [], + isSettingsLoaded: false, isFirstNetworkConnection: true, lastServerFetch: 0, lastServerFetchLibraryId: null, @@ -276,12 +277,25 @@ export default { this.isLoading = false }, - openMediaPlayerWithMostRecentListening() { + 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?.[0] if (mostRecentEntity) { @@ -356,11 +370,16 @@ 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() {