Fix mobile ereader for new data model

This commit is contained in:
advplyr 2022-04-16 06:10:10 -05:00
parent 066050700c
commit 6cea0ba03d
5 changed files with 60 additions and 45 deletions

View file

@ -141,7 +141,7 @@ export default {
return this.bookCoverAspectRatio === 1 return this.bookCoverAspectRatio === 1
}, },
sizeMultiplier() { sizeMultiplier() {
return this.width / 364 return Math.min(1, this.width / 364)
}, },
title() { title() {
return this.mediaMetadata.title || '' return this.mediaMetadata.title || ''

View file

@ -13,8 +13,6 @@
export default { export default {
data() { data() {
return { return {
ebookType: null,
ebookUrl: null,
touchstartX: 0, touchstartX: 0,
touchendX: 0 touchendX: 0
} }
@ -23,7 +21,6 @@ export default {
show: { show: {
handler(newVal) { handler(newVal) {
if (newVal) { if (newVal) {
this.init()
this.registerListeners() this.registerListeners()
} else { } else {
this.unregisterListeners() this.unregisterListeners()
@ -41,10 +38,16 @@ export default {
} }
}, },
title() { title() {
return this.selectedBook ? this.selectedBook.book.title : null return this.mediaMetadata.title || 'No Title'
}, },
selectedBook() { selectedLibraryItem() {
return this.$store.state.selectedBook return this.$store.state.selectedLibraryItem
},
media() {
return this.selectedLibraryItem ? this.selectedLibraryItem.media : null
},
mediaMetadata() {
return this.media ? this.media.metadata || {} : {}
}, },
readerComponentName() { readerComponentName() {
if (this.ebookType === 'epub') return 'readers-epub-reader' if (this.ebookType === 'epub') return 'readers-epub-reader'
@ -52,40 +55,52 @@ export default {
else if (this.ebookType === 'comic') return 'readers-comic-reader' else if (this.ebookType === 'comic') return 'readers-comic-reader'
return null return null
}, },
ebook() {
if (!this.selectedBook || !this.selectedBook.ebooks || !this.selectedBook.ebooks.length) return null
return this.selectedBook.ebooks[0]
},
ebookPath() {
return this.ebook ? this.ebook.path : null
},
folderId() { folderId() {
return this.selectedBook ? this.selectedBook.folderId : null return this.selectedLibraryItem ? this.selectedLibraryItem.folderId : null
}, },
libraryId() { libraryId() {
return this.selectedBook ? this.selectedBook.libraryId : null return this.selectedLibraryItem ? this.selectedLibraryItem.libraryId : null
}, },
ebookRelPath() { ebookFile() {
return `/ebook/${this.libraryId}/${this.folderId}/${this.ebookPath}` return this.media ? this.media.ebookFile : null
},
ebookFormat() {
if (!this.ebookFile) return null
return this.ebookFile.ebookFormat
},
ebookType() {
if (this.isMobi) return 'mobi'
else if (this.isEpub) return 'epub'
else if (this.isPdf) return 'pdf'
else if (this.isComic) return 'comic'
return null
},
isEpub() {
return this.ebookFormat == 'epub'
},
isMobi() {
return this.ebookFormat == 'mobi' || this.ebookFormat == 'azw3'
},
isPdf() {
return this.ebookFormat == 'pdf'
},
isComic() {
return this.ebookFormat == 'cbz' || this.ebookFormat == 'cbr'
},
ebookUrl() {
if (!this.ebookFile) return null
var itemRelPath = this.selectedLibraryItem.relPath
if (itemRelPath.startsWith('/')) itemRelPath = itemRelPath.slice(1)
var relPath = this.ebookFile.metadata.relPath
if (relPath.startsWith('/')) relPath = relPath.slice(1)
var serverAddress = this.$store.getters['user/getServerAddress']
return `${serverAddress}/ebook/${this.libraryId}/${this.folderId}/${itemRelPath}/${relPath}`
} }
}, },
methods: { methods: {
init() {
if (!this.ebook) {
console.error('No ebook for book', this.selectedBook)
return
}
if (this.ebook.ext === '.epub') {
this.ebookType = 'epub'
} else if (this.ebook.ext === '.mobi' || this.ebook.ext === '.azw3') {
this.ebookType = 'mobi'
} else if (this.ebook.ext === '.cbr' || this.ebook.ext === '.cbz') {
this.ebookType = 'comic'
}
var serverUrl = this.$store.state.serverUrl
this.ebookUrl = `${serverUrl}${this.ebookRelPath}`
},
next() { next() {
if (this.$refs.readerComponent && this.$refs.readerComponent.next) { if (this.$refs.readerComponent && this.$refs.readerComponent.next) {
this.$refs.readerComponent.next() this.$refs.readerComponent.next()

View file

@ -9,13 +9,13 @@ install! 'cocoapods', :disable_input_output_paths => true
def capacitor_pods def capacitor_pods
pod 'Capacitor', :path => '../../node_modules/@capacitor/ios' pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'
pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios' pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'
pod 'CapacitorApp', :path => '../../node_modules/@capacitor/app' pod 'CapacitorApp', :path => '..\..\node_modules\@capacitor\app'
pod 'CapacitorDialog', :path => '../../node_modules/@capacitor/dialog' pod 'CapacitorDialog', :path => '..\..\node_modules\@capacitor\dialog'
pod 'CapacitorHaptics', :path => '../../node_modules/@capacitor/haptics' pod 'CapacitorHaptics', :path => '..\..\node_modules\@capacitor\haptics'
pod 'CapacitorNetwork', :path => '../../node_modules/@capacitor/network' pod 'CapacitorNetwork', :path => '..\..\node_modules\@capacitor\network'
pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar' pod 'CapacitorStatusBar', :path => '..\..\node_modules\@capacitor\status-bar'
pod 'CapacitorStorage', :path => '../../node_modules/@capacitor/storage' pod 'CapacitorStorage', :path => '..\..\node_modules\@capacitor\storage'
pod 'RobingenzCapacitorAppUpdate', :path => '../../node_modules/@robingenz/capacitor-app-update' pod 'RobingenzCapacitorAppUpdate', :path => '..\..\node_modules\@robingenz\capacitor-app-update'
end end
target 'App' do target 'App' do

View file

@ -215,7 +215,7 @@ export default {
return !this.isMissing && !this.isIncomplete && this.numTracks return !this.isMissing && !this.isIncomplete && this.numTracks
}, },
showRead() { showRead() {
return this.ebookFile && this.ebookFormat !== '.pdf' return this.ebookFile && this.ebookFormat !== 'pdf'
}, },
ebookFile() { ebookFile() {
return this.media.ebookFile return this.media.ebookFile

View file

@ -11,7 +11,7 @@ export const state = () => ({
networkConnectionType: null, networkConnectionType: null,
isFirstLoad: true, isFirstLoad: true,
hasStoragePermission: false, hasStoragePermission: false,
selectedBook: null, selectedLibraryItem: null,
showReader: false, showReader: false,
showSideDrawer: false, showSideDrawer: false,
isNetworkListenerInit: false, isNetworkListenerInit: false,
@ -91,8 +91,8 @@ export const mutations = {
state.networkConnected = val.connected state.networkConnected = val.connected
state.networkConnectionType = val.connectionType state.networkConnectionType = val.connectionType
}, },
openReader(state, audiobook) { openReader(state, libraryItem) {
state.selectedBook = audiobook state.selectedLibraryItem = libraryItem
state.showReader = true state.showReader = true
}, },
setShowReader(state, val) { setShowReader(state, val) {