mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-07-30 07:34:46 +02:00
Fix:Remove last saved library id when changing servers so home page shelves load on init
This commit is contained in:
parent
d7dcaa22a6
commit
870774b408
10 changed files with 33 additions and 16 deletions
|
@ -122,11 +122,15 @@ export default {
|
|||
this.show = false
|
||||
},
|
||||
async logout() {
|
||||
if (this.user) {
|
||||
await this.$axios.$post('/logout').catch((error) => {
|
||||
console.error(error)
|
||||
})
|
||||
}
|
||||
|
||||
this.$socket.logout()
|
||||
await this.$db.logout()
|
||||
this.$localStore.removeLastLibraryId()
|
||||
this.$store.commit('user/logout')
|
||||
this.$router.push('/connect')
|
||||
},
|
||||
|
|
|
@ -382,7 +382,7 @@ export default {
|
|||
this.resetEntities()
|
||||
}
|
||||
},
|
||||
libraryChanged(libid) {
|
||||
libraryChanged() {
|
||||
if (this.hasFilter) {
|
||||
this.clearFilter()
|
||||
} else {
|
||||
|
|
|
@ -51,7 +51,7 @@ export default {
|
|||
async clickedOption(lib) {
|
||||
this.show = false
|
||||
await this.$store.dispatch('libraries/fetch', lib.id)
|
||||
this.$eventBus.$emit('library-changed', lib.id)
|
||||
this.$eventBus.$emit('library-changed')
|
||||
this.$localStore.setLastLibraryId(lib.id)
|
||||
}
|
||||
},
|
||||
|
|
|
@ -170,8 +170,8 @@ export default {
|
|||
this.inittingLibraries = true
|
||||
await this.$store.dispatch('libraries/load')
|
||||
console.log(`[default] initLibraries loaded ${this.currentLibraryId}`)
|
||||
await this.$store.dispatch('libraries/fetch', this.currentLibraryId)
|
||||
this.$eventBus.$emit('library-changed')
|
||||
this.$store.dispatch('libraries/fetch', this.currentLibraryId)
|
||||
this.inittingLibraries = false
|
||||
},
|
||||
async syncLocalMediaProgress() {
|
||||
|
|
|
@ -53,11 +53,15 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
async logout() {
|
||||
if (this.user) {
|
||||
await this.$axios.$post('/logout').catch((error) => {
|
||||
console.error(error)
|
||||
})
|
||||
}
|
||||
|
||||
this.$socket.logout()
|
||||
await this.$db.logout()
|
||||
this.$localStore.removeLastLibraryId()
|
||||
this.$store.commit('user/logout')
|
||||
this.$router.push('/connect')
|
||||
}
|
||||
|
|
|
@ -4,10 +4,6 @@
|
|||
<home-bookshelf-toolbar v-show="!isHome" />
|
||||
<div id="bookshelf-wrapper" class="main-content overflow-y-auto overflow-x-hidden relative" :class="isHome ? 'home-page' : ''">
|
||||
<nuxt-child />
|
||||
|
||||
<!-- <div v-if="isLoading" class="absolute top-0 left-0 w-full h-full flex items-center justify-center">
|
||||
<ui-loading-indicator />
|
||||
</div>-->
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -135,7 +135,7 @@ export default {
|
|||
}
|
||||
this.loading = false
|
||||
},
|
||||
async libraryChanged(libid) {
|
||||
async libraryChanged() {
|
||||
if (this.currentLibraryId) {
|
||||
await this.fetchCategories()
|
||||
}
|
||||
|
|
|
@ -83,7 +83,16 @@ class LocalStorage {
|
|||
await Storage.set({ key: 'lastLibraryId', value: libraryId })
|
||||
console.log('[LocalStorage] Set Last Library Id', libraryId)
|
||||
} catch (error) {
|
||||
console.error('[LocalStorage] Failed to set current library', error)
|
||||
console.error('[LocalStorage] Failed to set last library id', error)
|
||||
}
|
||||
}
|
||||
|
||||
async removeLastLibraryId() {
|
||||
try {
|
||||
await Storage.remove({ key: 'lastLibraryId' })
|
||||
console.log('[LocalStorage] Remove Last Library Id')
|
||||
} catch (error) {
|
||||
console.error('[LocalStorage] Failed to remove last library id', error)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,13 +22,16 @@ export const getters = {
|
|||
if (media.coverPath.startsWith('http:') || media.coverPath.startsWith('https:')) return media.coverPath
|
||||
|
||||
var userToken = rootGetters['user/getToken']
|
||||
var serverAddress = rootGetters['user/getServerAddress']
|
||||
if (!userToken || !serverAddress) return placeholder
|
||||
|
||||
var lastUpdate = libraryItem.updatedAt || Date.now()
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') { // Testing
|
||||
// return `http://localhost:3333/api/items/${libraryItem.id}/cover?token=${userToken}&ts=${lastUpdate}`
|
||||
}
|
||||
|
||||
var url = new URL(`/api/items/${libraryItem.id}/cover`, rootGetters['user/getServerAddress'])
|
||||
var url = new URL(`/api/items/${libraryItem.id}/cover`, serverAddress)
|
||||
return `${url}?token=${userToken}&ts=${lastUpdate}`
|
||||
},
|
||||
getLocalMediaProgressById: (state) => (localLibraryItemId, episodeId = null) => {
|
||||
|
|
|
@ -90,6 +90,7 @@ export const mutations = {
|
|||
},
|
||||
reset(state) {
|
||||
state.lastLoad = 0
|
||||
state.currentLibraryId = null
|
||||
state.libraries = []
|
||||
},
|
||||
setCurrentLibrary(state, val) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue