diff --git a/components/app/AudioPlayer.vue b/components/app/AudioPlayer.vue index e8353625..9fdc0433 100644 --- a/components/app/AudioPlayer.vue +++ b/components/app/AudioPlayer.vue @@ -205,7 +205,7 @@ export default { return this.$store.getters['getJumpBackwardsTime'] }, bookCoverAspectRatio() { - return this.$store.getters['getBookCoverAspectRatio'] + return this.$store.getters['libraries/getBookCoverAspectRatio'] }, bookCoverWidth() { if (this.showFullscreen) return this.fullscreenBookCoverWidth diff --git a/components/bookshelf/LazyBookshelf.vue b/components/bookshelf/LazyBookshelf.vue index 8060af68..7cc1e53d 100644 --- a/components/bookshelf/LazyBookshelf.vue +++ b/components/bookshelf/LazyBookshelf.vue @@ -89,7 +89,7 @@ export default { return this.bookCoverAspectRatio === 1 }, bookCoverAspectRatio() { - return this.$store.getters['getBookCoverAspectRatio'] + return this.$store.getters['libraries/getBookCoverAspectRatio'] }, bookWidth() { var coverSize = 100 diff --git a/components/bookshelf/Shelf.vue b/components/bookshelf/Shelf.vue index 35052e68..a95b30f2 100644 --- a/components/bookshelf/Shelf.vue +++ b/components/bookshelf/Shelf.vue @@ -69,7 +69,7 @@ export default { return this.bookCoverAspectRatio === 1 }, bookCoverAspectRatio() { - return this.$store.getters['getBookCoverAspectRatio'] + return this.$store.getters['libraries/getBookCoverAspectRatio'] }, altViewEnabled() { return this.$store.getters['getAltViewEnabled'] diff --git a/components/cards/ItemSearchCard.vue b/components/cards/ItemSearchCard.vue index 838a0cd5..bc368120 100644 --- a/components/cards/ItemSearchCard.vue +++ b/components/cards/ItemSearchCard.vue @@ -31,7 +31,7 @@ export default { }, computed: { bookCoverAspectRatio() { - return this.$store.getters['getBookCoverAspectRatio'] + return this.$store.getters['libraries/getBookCoverAspectRatio'] }, coverWidth() { if (this.bookCoverAspectRatio === 1) return 50 * 1.2 diff --git a/components/cards/SeriesSearchCard.vue b/components/cards/SeriesSearchCard.vue index 67fdabd0..754de2bc 100644 --- a/components/cards/SeriesSearchCard.vue +++ b/components/cards/SeriesSearchCard.vue @@ -24,7 +24,7 @@ export default { }, computed: { bookCoverAspectRatio() { - return this.$store.getters['getBookCoverAspectRatio'] + return this.$store.getters['libraries/getBookCoverAspectRatio'] }, name() { return this.series.name diff --git a/components/modals/FullscreenCover.vue b/components/modals/FullscreenCover.vue index a363a97a..d5e71e2e 100644 --- a/components/modals/FullscreenCover.vue +++ b/components/modals/FullscreenCover.vue @@ -40,7 +40,7 @@ export default { } }, bookCoverAspectRatio() { - return this.$store.getters['getBookCoverAspectRatio'] + return this.$store.getters['libraries/getBookCoverAspectRatio'] } }, methods: { diff --git a/components/tables/collection/BookTableRow.vue b/components/tables/collection/BookTableRow.vue index 72ca46d8..cc3af0df 100644 --- a/components/tables/collection/BookTableRow.vue +++ b/components/tables/collection/BookTableRow.vue @@ -50,7 +50,7 @@ export default { return this.$elapsedPretty(this.media.duration) }, bookCoverAspectRatio() { - return this.$store.getters['getBookCoverAspectRatio'] + return this.$store.getters['libraries/getBookCoverAspectRatio'] }, bookWidth() { if (this.bookCoverAspectRatio === 1) return 50 diff --git a/pages/collection/_id.vue b/pages/collection/_id.vue index 5d439c38..8a0da8ff 100644 --- a/pages/collection/_id.vue +++ b/pages/collection/_id.vue @@ -58,7 +58,7 @@ export default { }, computed: { bookCoverAspectRatio() { - return this.$store.getters['getBookCoverAspectRatio'] + return this.$store.getters['libraries/getBookCoverAspectRatio'] }, bookItems() { return this.collection.books || [] diff --git a/pages/item/_id.vue b/pages/item/_id.vue index 3a7a4b94..34cc49ba 100644 --- a/pages/item/_id.vue +++ b/pages/item/_id.vue @@ -199,7 +199,7 @@ export default { return null }, bookCoverAspectRatio() { - return this.$store.getters['getBookCoverAspectRatio'] + return this.$store.getters['libraries/getBookCoverAspectRatio'] }, libraryItemId() { return this.libraryItem.id diff --git a/pages/search.vue b/pages/search.vue index 6893f0ec..cb7c4ed6 100644 --- a/pages/search.vue +++ b/pages/search.vue @@ -68,7 +68,7 @@ export default { return this.$store.state.libraries.currentLibraryId }, bookCoverAspectRatio() { - return this.$store.getters['getBookCoverAspectRatio'] + return this.$store.getters['libraries/getBookCoverAspectRatio'] }, totalResults() { return this.bookResults.length + this.seriesResults.length + this.authorResults.length + this.podcastResults.length diff --git a/plugins/constants.js b/plugins/constants.js index e6e84210..34a1344d 100644 --- a/plugins/constants.js +++ b/plugins/constants.js @@ -45,7 +45,8 @@ const Constants = { } export { - PlayerState + PlayerState, + BookCoverAspectRatio } export default ({ app }, inject) => { diff --git a/store/index.js b/store/index.js index cb8dbc8b..3a6509e8 100644 --- a/store/index.js +++ b/store/index.js @@ -36,10 +36,6 @@ export const getters = { if (!state.serverSettings) return null return state.serverSettings[key] }, - getBookCoverAspectRatio: state => { - if (!state.serverSettings) return 1 - return state.serverSettings.coverAspectRatio === 0 ? 1.6 : 1 - }, getJumpForwardTime: state => { if (!state.deviceData || !state.deviceData.deviceSettings) return 10 return state.deviceData.deviceSettings.jumpForwardTime || 10 diff --git a/store/libraries.js b/store/libraries.js index af868897..ff8b7247 100644 --- a/store/libraries.js +++ b/store/libraries.js @@ -1,3 +1,5 @@ +const { BookCoverAspectRatio } = require('../plugins/constants') + export const state = () => ({ libraries: [], lastLoad: 0, @@ -18,6 +20,14 @@ export const getters = { getCurrentLibraryMediaType: (state, getters) => { var currLib = getters.getCurrentLibrary return currLib ? currLib.mediaType : null + }, + getCurrentLibrarySettings: (state, getters) => { + if (!getters.getCurrentLibrary) return null + return getters.getCurrentLibrary.settings + }, + getBookCoverAspectRatio: (state, getters) => { + if (!getters.getCurrentLibrarySettings || isNaN(getters.getCurrentLibrarySettings.coverAspectRatio)) return 1 + return getters.getCurrentLibrarySettings.coverAspectRatio === BookCoverAspectRatio.STANDARD ? 1.6 : 1 } }