From 322cad554837f666e5096b4248a768b1f54ffeb7 Mon Sep 17 00:00:00 2001 From: advplyr Date: Mon, 1 Jan 2024 08:22:20 -0600 Subject: [PATCH] Move AbsAudioPlayer.setChapterTrack to AudioPlayer instead of localStore --- components/app/AudioPlayer.vue | 11 +++++++++-- plugins/localStore.js | 6 ------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/components/app/AudioPlayer.vue b/components/app/AudioPlayer.vue index 3bd04383..2dffde54 100644 --- a/components/app/AudioPlayer.vue +++ b/components/app/AudioPlayer.vue @@ -695,8 +695,8 @@ export default { this.updateTimestamp() this.updateTrack() this.updateReadyTrack() + this.updateUseChapterTrack() this.$localStore.setUseTotalTrack(this.useTotalTrack) - this.$localStore.setUseChapterTrack(this.useChapterTrack) } else if (action === 'total_track') { this.useTotalTrack = !this.useTotalTrack this.useChapterTrack = !this.useTotalTrack || this.useChapterTrack @@ -704,13 +704,20 @@ export default { this.updateTimestamp() this.updateTrack() this.updateReadyTrack() + this.updateUseChapterTrack() this.$localStore.setUseTotalTrack(this.useTotalTrack) - this.$localStore.setUseChapterTrack(this.useChapterTrack) } else if (action === 'close') { this.closePlayback() } }) }, + updateUseChapterTrack() { + this.$localStore.setUseChapterTrack(this.useChapterTrack) + // Chapter track in NowPlaying only supported on iOS for now + if (this.$platform === 'ios') { + AbsAudioPlayer.setChapterTrack({ enabled: this.useChapterTrack }) + } + }, forceCloseDropdownMenu() { if (this.$refs.dropdownMenu && this.$refs.dropdownMenu.closeMenu) { this.$refs.dropdownMenu.closeMenu() diff --git a/plugins/localStore.js b/plugins/localStore.js index 7f240ca6..009aa6e0 100644 --- a/plugins/localStore.js +++ b/plugins/localStore.js @@ -1,7 +1,4 @@ import { Preferences } from '@capacitor/preferences' -import { AbsAudioPlayer } from '@/plugins/capacitor' -import { Capacitor } from '@capacitor/core' - class LocalStorage { constructor(vuexStore) { @@ -48,9 +45,6 @@ class LocalStorage { async setUseChapterTrack(useChapterTrack) { try { await Preferences.set({ key: 'useChapterTrack', value: useChapterTrack ? '1' : '0' }) - if (Capacitor.getPlatform() === 'ios') { - AbsAudioPlayer.setChapterTrack({ enabled: useChapterTrack }) - } } catch (error) { console.error('[LocalStorage] Failed to set use chapter track', error) }