mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-08-06 20:08:48 +02:00
Fix plugin listener handlers, add message for configs using old server auth, show server version on account page
This commit is contained in:
@@ -100,14 +100,14 @@ export default {
|
||||
this.isCastAvailable = data && data.value
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
async mounted() {
|
||||
AbsAudioPlayer.getIsCastAvailable().then((data) => {
|
||||
this.isCastAvailable = data && data.value
|
||||
})
|
||||
this.onCastAvailableUpdateListener = AbsAudioPlayer.addListener('onCastAvailableUpdate', this.onCastAvailableUpdate)
|
||||
this.onCastAvailableUpdateListener = await AbsAudioPlayer.addListener('onCastAvailableUpdate', this.onCastAvailableUpdate)
|
||||
},
|
||||
beforeDestroy() {
|
||||
if (this.onCastAvailableUpdateListener) this.onCastAvailableUpdateListener.remove()
|
||||
this.onCastAvailableUpdateListener?.remove()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -140,13 +140,6 @@ export default {
|
||||
readyTrackWidth: 0,
|
||||
seekedTime: 0,
|
||||
seekLoading: false,
|
||||
onPlaybackSessionListener: null,
|
||||
onPlaybackClosedListener: null,
|
||||
onPlayingUpdateListener: null,
|
||||
onMetadataListener: null,
|
||||
onProgressSyncFailing: null,
|
||||
onProgressSyncSuccess: null,
|
||||
onPlaybackSpeedChangedListener: null,
|
||||
touchStartY: 0,
|
||||
touchStartTime: 0,
|
||||
playerSettings: {
|
||||
@@ -883,14 +876,14 @@ export default {
|
||||
async init() {
|
||||
await this.loadPlayerSettings()
|
||||
|
||||
this.onPlaybackSessionListener = AbsAudioPlayer.addListener('onPlaybackSession', this.onPlaybackSession)
|
||||
this.onPlaybackClosedListener = AbsAudioPlayer.addListener('onPlaybackClosed', this.onPlaybackClosed)
|
||||
this.onPlaybackFailedListener = AbsAudioPlayer.addListener('onPlaybackFailed', this.onPlaybackFailed)
|
||||
this.onPlayingUpdateListener = AbsAudioPlayer.addListener('onPlayingUpdate', this.onPlayingUpdate)
|
||||
this.onMetadataListener = AbsAudioPlayer.addListener('onMetadata', this.onMetadata)
|
||||
this.onProgressSyncFailing = AbsAudioPlayer.addListener('onProgressSyncFailing', this.showProgressSyncIsFailing)
|
||||
this.onProgressSyncSuccess = AbsAudioPlayer.addListener('onProgressSyncSuccess', this.showProgressSyncSuccess)
|
||||
this.onPlaybackSpeedChangedListener = AbsAudioPlayer.addListener('onPlaybackSpeedChanged', this.onPlaybackSpeedChanged)
|
||||
AbsAudioPlayer.addListener('onPlaybackSession', this.onPlaybackSession)
|
||||
AbsAudioPlayer.addListener('onPlaybackClosed', this.onPlaybackClosed)
|
||||
AbsAudioPlayer.addListener('onPlaybackFailed', this.onPlaybackFailed)
|
||||
AbsAudioPlayer.addListener('onPlayingUpdate', this.onPlayingUpdate)
|
||||
AbsAudioPlayer.addListener('onMetadata', this.onMetadata)
|
||||
AbsAudioPlayer.addListener('onProgressSyncFailing', this.showProgressSyncIsFailing)
|
||||
AbsAudioPlayer.addListener('onProgressSyncSuccess', this.showProgressSyncSuccess)
|
||||
AbsAudioPlayer.addListener('onPlaybackSpeedChanged', this.onPlaybackSpeedChanged)
|
||||
},
|
||||
async screenOrientationChange() {
|
||||
if (this.isRefreshingUI) return
|
||||
@@ -984,14 +977,9 @@ export default {
|
||||
document.body.removeEventListener('touchend', this.touchend)
|
||||
document.body.removeEventListener('touchmove', this.touchmove)
|
||||
|
||||
if (this.onPlayingUpdateListener) this.onPlayingUpdateListener.remove()
|
||||
if (this.onMetadataListener) this.onMetadataListener.remove()
|
||||
if (this.onPlaybackSessionListener) this.onPlaybackSessionListener.remove()
|
||||
if (this.onPlaybackClosedListener) this.onPlaybackClosedListener.remove()
|
||||
if (this.onPlaybackFailedListener) this.onPlaybackFailedListener.remove()
|
||||
if (this.onProgressSyncFailing) this.onProgressSyncFailing.remove()
|
||||
if (this.onProgressSyncSuccess) this.onProgressSyncSuccess.remove()
|
||||
if (this.onPlaybackSpeedChangedListener) this.onPlaybackSpeedChangedListener.remove()
|
||||
if (AbsAudioPlayer.removeAllListeners) {
|
||||
AbsAudioPlayer.removeAllListeners()
|
||||
}
|
||||
clearInterval(this.playInterval)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,11 +351,11 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.onLocalMediaProgressUpdateListener = AbsAudioPlayer.addListener('onLocalMediaProgressUpdate', this.onLocalMediaProgressUpdate)
|
||||
this.onSleepTimerEndedListener = AbsAudioPlayer.addListener('onSleepTimerEnded', this.onSleepTimerEnded)
|
||||
this.onSleepTimerSetListener = AbsAudioPlayer.addListener('onSleepTimerSet', this.onSleepTimerSet)
|
||||
this.onMediaPlayerChangedListener = AbsAudioPlayer.addListener('onMediaPlayerChanged', this.onMediaPlayerChanged)
|
||||
async mounted() {
|
||||
this.onLocalMediaProgressUpdateListener = await AbsAudioPlayer.addListener('onLocalMediaProgressUpdate', this.onLocalMediaProgressUpdate)
|
||||
this.onSleepTimerEndedListener = await AbsAudioPlayer.addListener('onSleepTimerEnded', this.onSleepTimerEnded)
|
||||
this.onSleepTimerSetListener = await AbsAudioPlayer.addListener('onSleepTimerSet', this.onSleepTimerSet)
|
||||
this.onMediaPlayerChangedListener = await AbsAudioPlayer.addListener('onMediaPlayerChanged', this.onMediaPlayerChanged)
|
||||
|
||||
this.playbackSpeed = this.$store.getters['user/getUserSetting']('playbackRate')
|
||||
console.log(`[AudioPlayerContainer] Init Playback Speed: ${this.playbackSpeed}`)
|
||||
@@ -370,10 +370,10 @@ export default {
|
||||
this.$eventBus.$on('device-focus-update', this.deviceFocused)
|
||||
},
|
||||
beforeDestroy() {
|
||||
if (this.onLocalMediaProgressUpdateListener) this.onLocalMediaProgressUpdateListener.remove()
|
||||
if (this.onSleepTimerEndedListener) this.onSleepTimerEndedListener.remove()
|
||||
if (this.onSleepTimerSetListener) this.onSleepTimerSetListener.remove()
|
||||
if (this.onMediaPlayerChangedListener) this.onMediaPlayerChangedListener.remove()
|
||||
this.onLocalMediaProgressUpdateListener?.remove()
|
||||
this.onSleepTimerEndedListener?.remove()
|
||||
this.onSleepTimerSetListener?.remove()
|
||||
this.onMediaPlayerChangedListener?.remove()
|
||||
|
||||
this.$eventBus.$off('abs-ui-ready', this.onReady)
|
||||
this.$eventBus.$off('play-item', this.playLibraryItem)
|
||||
|
||||
@@ -17,6 +17,11 @@
|
||||
<p class="text-xs text-warning">{{ $strings.MessageOldServerConnectionWarning }}</p>
|
||||
<ui-btn class="text-xs whitespace-nowrap" :padding-x="2" :padding-y="1" @click="showOldUserIdWarningDialog">{{ $strings.LabelMoreInfo }}</ui-btn>
|
||||
</div>
|
||||
<!-- warning message if server connection config is using an old auth method -->
|
||||
<div v-if="config.version && checkIsUsingOldAuth(config)" class="flex flex-nowrap justify-between items-center space-x-4 pt-4">
|
||||
<p class="text-xs text-warning">{{ $strings.MessageOldServerAuthWarning }}</p>
|
||||
<ui-btn class="text-xs whitespace-nowrap" :padding-x="2" :padding-y="1" @click="showOldAuthWarningDialog">{{ $strings.LabelMoreInfo }}</ui-btn>
|
||||
</div>
|
||||
</div>
|
||||
<div class="my-1 py-4 w-full">
|
||||
<ui-btn class="w-full" @click="newServerConfigClick">{{ $strings.ButtonAddNewServer }}</ui-btn>
|
||||
@@ -155,9 +160,20 @@ export default {
|
||||
cancelText: this.$strings.ButtonOk
|
||||
})
|
||||
},
|
||||
showOldAuthWarningDialog() {
|
||||
Dialog.alert({
|
||||
title: 'Old Server Auth Warning',
|
||||
message: this.$strings.MessageOldServerAuthWarningHelp,
|
||||
cancelText: this.$strings.ButtonOk
|
||||
})
|
||||
},
|
||||
checkIdUuid(userId) {
|
||||
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(userId)
|
||||
},
|
||||
checkIsUsingOldAuth(config) {
|
||||
if (!config.version) return true
|
||||
return !this.$isValidVersion(config.version, '2.26.0')
|
||||
},
|
||||
/**
|
||||
* Initiates the login process using OpenID via OAuth2.0.
|
||||
* 1. Verifying the server's address
|
||||
@@ -505,7 +521,7 @@ export default {
|
||||
try {
|
||||
var urlObject = new URL(url)
|
||||
if (protocolOverride) urlObject.protocol = protocolOverride
|
||||
return urlObject.href
|
||||
return urlObject.href.replace(/\/$/, '') // Remove trailing slash
|
||||
} catch (error) {
|
||||
console.error('Invalid URL', error)
|
||||
return null
|
||||
@@ -889,7 +905,7 @@ export default {
|
||||
return authRes
|
||||
},
|
||||
setForceReloginForNewAuth() {
|
||||
this.error = 'A new authentication system was added in server v2.26.0. Re-login is required for this server connection.'
|
||||
this.error = this.$strings.MessageOldServerAuthReLoginRequired
|
||||
this.showAuth = true
|
||||
},
|
||||
init() {
|
||||
|
||||
@@ -245,6 +245,7 @@ export default {
|
||||
async extract() {
|
||||
this.loading = true
|
||||
|
||||
// TODO: Handle JWT auth refresh
|
||||
const buff = await this.$axios.$get(this.url, {
|
||||
responseType: 'blob',
|
||||
headers: {
|
||||
|
||||
@@ -84,6 +84,7 @@ export default {
|
||||
},
|
||||
async initMobi() {
|
||||
// Fetch mobi file as blob
|
||||
// TODO: Handle JWT auth refresh
|
||||
var buff = await this.$axios.$get(this.url, {
|
||||
responseType: 'blob',
|
||||
headers: {
|
||||
|
||||
@@ -78,15 +78,15 @@ export default {
|
||||
this.$store.commit('globals/updateDownloadItemPart', itemPart)
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.downloadItemListener = AbsDownloader.addListener('onDownloadItem', (data) => this.onDownloadItem(data))
|
||||
this.itemPartUpdateListener = AbsDownloader.addListener('onDownloadItemPartUpdate', (data) => this.onDownloadItemPartUpdate(data))
|
||||
this.completeListener = AbsDownloader.addListener('onItemDownloadComplete', (data) => this.onItemDownloadComplete(data))
|
||||
async mounted() {
|
||||
this.downloadItemListener = await AbsDownloader.addListener('onDownloadItem', (data) => this.onDownloadItem(data))
|
||||
this.itemPartUpdateListener = await AbsDownloader.addListener('onDownloadItemPartUpdate', (data) => this.onDownloadItemPartUpdate(data))
|
||||
this.completeListener = await AbsDownloader.addListener('onItemDownloadComplete', (data) => this.onItemDownloadComplete(data))
|
||||
},
|
||||
beforeDestroy() {
|
||||
if (this.downloadItemListener) this.downloadItemListener.remove()
|
||||
if (this.completeListener) this.completeListener.remove()
|
||||
if (this.itemPartUpdateListener) this.itemPartUpdateListener.remove()
|
||||
this.downloadItemListener?.remove()
|
||||
this.completeListener?.remove()
|
||||
this.itemPartUpdateListener?.remove()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user