mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-08-26 05:14:09 +02:00
New data model updates for bookshelf, covers, cards
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
export const state = () => ({
|
||||
|
||||
})
|
||||
|
||||
export const getters = {
|
||||
getLibraryItemCoverSrc: (state, getters, rootState, rootGetters) => (libraryItem, placeholder = '/book_placeholder.jpg') => {
|
||||
if (!libraryItem) return placeholder
|
||||
var media = libraryItem.media
|
||||
if (!media || !media.coverPath || media.coverPath === placeholder) return placeholder
|
||||
|
||||
// Absolute URL covers (should no longer be used)
|
||||
if (media.coverPath.startsWith('http:') || media.coverPath.startsWith('https:')) return media.coverPath
|
||||
|
||||
var userToken = rootGetters['user/getToken']
|
||||
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`, rootState.serverUrl)
|
||||
return `${url}?token=${userToken}&ts=${lastUpdate}`
|
||||
}
|
||||
}
|
||||
|
||||
export const actions = {
|
||||
|
||||
}
|
||||
|
||||
export const mutations = {
|
||||
|
||||
}
|
||||
+4
-6
@@ -2,6 +2,7 @@ import Vue from 'vue'
|
||||
import { Network } from '@capacitor/network'
|
||||
|
||||
export const state = () => ({
|
||||
streamLibraryItem: null,
|
||||
streamAudiobook: null,
|
||||
playingDownload: null,
|
||||
playOnLoad: false,
|
||||
@@ -80,6 +81,9 @@ export const mutations = {
|
||||
setPlayOnLoad(state, val) {
|
||||
state.playOnLoad = val
|
||||
},
|
||||
setLibraryItemStream(state, libraryItem) {
|
||||
state.streamLibraryItem = libraryItem
|
||||
},
|
||||
setStreamAudiobook(state, audiobook) {
|
||||
if (audiobook) {
|
||||
state.playingDownload = null
|
||||
@@ -111,12 +115,6 @@ export const mutations = {
|
||||
state.networkConnected = val.connected
|
||||
state.networkConnectionType = val.connectionType
|
||||
},
|
||||
setStreamListener(state, val) {
|
||||
state.streamListener = val
|
||||
},
|
||||
removeStreamListener(state) {
|
||||
state.streamListener = null
|
||||
},
|
||||
openReader(state, audiobook) {
|
||||
state.selectedBook = audiobook
|
||||
state.showReader = true
|
||||
|
||||
@@ -20,6 +20,10 @@ export const getters = {
|
||||
getToken: (state) => {
|
||||
return state.user ? state.user.token : null
|
||||
},
|
||||
getUserLibraryItemProgress: (state) => (libraryItemId) => {
|
||||
if (!state.user.libraryItemProgress) return null
|
||||
return state.user.libraryItemProgress.find(li => li.id == libraryItemId)
|
||||
},
|
||||
getUserAudiobookData: (state, getters) => (audiobookId) => {
|
||||
return getters.getUserAudiobook(audiobookId)
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user