diff --git a/components/bookshelf/LazyBookshelf.vue b/components/bookshelf/LazyBookshelf.vue index 2cdaf3eb..803a22d3 100644 --- a/components/bookshelf/LazyBookshelf.vue +++ b/components/bookshelf/LazyBookshelf.vue @@ -319,7 +319,6 @@ export default { if (this.isFirstInit) return this.isFirstInit = true this.initSizeData() - await this.loadPage(0) var lastBookIndex = Math.min(this.totalEntities, this.shelvesPerPage * this.entitiesPerShelf) this.mountEntites(0, lastBookIndex) diff --git a/layouts/default.vue b/layouts/default.vue index 7a7667db..65cae499 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -56,7 +56,8 @@ export default { this.initSocketListeners() // Load libraries - this.$store.dispatch('libraries/load') + await this.$store.dispatch('libraries/load') + this.$eventBus.$emit('library-changed') this.$store.dispatch('libraries/fetch', this.currentLibraryId) } else { this.removeSocketListeners() diff --git a/pages/bookshelf/index.vue b/pages/bookshelf/index.vue index 1fd132a7..3cf91544 100644 --- a/pages/bookshelf/index.vue +++ b/pages/bookshelf/index.vue @@ -18,10 +18,7 @@ cloud_off

Audiobookshelf server not connected.

-

- Important! This app requires that you are running - your own server and does not provide any content. -

+

Important! This app requires that you are running your own server and does not provide any content.

Connect @@ -136,7 +133,7 @@ export default { this.shelves = categories }, async socketInit(isConnected) { - if (isConnected) { + if (isConnected && this.currentLibraryId) { console.log('Connected - Load from server') await this.fetchCategories() } else { @@ -146,8 +143,7 @@ export default { this.loading = false }, async libraryChanged(libid) { - console.log('Library changed', libid) - if (this.isSocketConnected) { + if (this.isSocketConnected && this.currentLibraryId) { await this.fetchCategories() } else { this.shelves = this.downloadOnlyShelves @@ -246,7 +242,7 @@ export default { }, mounted() { this.initListeners() - if (this.$server.initialized) { + if (this.$server.initialized && this.currentLibraryId) { this.fetchCategories() } else { this.shelves = this.downloadOnlyShelves diff --git a/pages/downloads.vue b/pages/downloads.vue index b86a6ffe..dbd1d48a 100644 --- a/pages/downloads.vue +++ b/pages/downloads.vue @@ -31,26 +31,22 @@

No Downloads

diff --git a/plugins/sqlStore.js b/plugins/sqlStore.js index a0e2e13b..7f8d5e5f 100644 --- a/plugins/sqlStore.js +++ b/plugins/sqlStore.js @@ -23,7 +23,6 @@ class StoreService { init() { this.platform = Capacitor.getPlatform() this.store = CapacitorDataStorageSqlite - console.log('in init ', this.platform) } /** diff --git a/store/audiobooks.js b/store/audiobooks.js index 7ea0078d..6c17bdc9 100644 --- a/store/audiobooks.js +++ b/store/audiobooks.js @@ -18,7 +18,7 @@ export const getters = { console.error('No book item id', bookItem) } if (process.env.NODE_ENV !== 'production') { // Testing - return `http://localhost:3333/api/books/${bookItem.id}/cover?token=${userToken}&ts=${bookLastUpdate}` + // return `http://localhost:3333/api/books/${bookItem.id}/cover?token=${userToken}&ts=${bookLastUpdate}` } var url = new URL(`/api/books/${bookItem.id}/cover`, rootState.serverUrl) diff --git a/store/libraries.js b/store/libraries.js index 88338b3d..fcb50ee2 100644 --- a/store/libraries.js +++ b/store/libraries.js @@ -2,7 +2,7 @@ export const state = () => ({ libraries: [], lastLoad: 0, listeners: [], - currentLibraryId: 'main', + currentLibraryId: '', showModal: false, folders: [], folderLastUpdate: 0, @@ -65,17 +65,23 @@ export const actions = { return false } - this.$axios + return this.$axios .$get(`/api/libraries`) .then((data) => { + // Set current library + if (data.length) { + commit('setCurrentLibrary', data[0].id) + } + commit('set', data) commit('setLastLoad') + return true }) .catch((error) => { console.error('Failed', error) commit('set', []) + return false }) - return true }, }