Enhanced download series ui

- Move download button from menu to toolbar
- Changed download confirmation message
- Changed serie to series
This commit is contained in:
ISO-B 2024-09-07 23:30:10 +03:00
parent 84509ec1a8
commit 34dcdc89c3
3 changed files with 20 additions and 32 deletions

View file

@ -13,6 +13,7 @@
</div>
<span class="material-icons px-2" @click="showSortModal = true">sort</span>
</template>
<span v-if="seriesBookPage" class="material-icons px-2" @click="downloadSeries">download</span>
<span v-if="(page == 'library' && isBookLibrary) || seriesBookPage" class="material-icons px-2" @click="showMoreMenuDialog = true">more_vert</span>
</div>
</div>
@ -95,11 +96,6 @@ export default {
text: this.$strings.LabelCollapseSeries,
value: 'collapse_subseries',
icon: this.settings.collapseBookSeries ? 'check_box' : 'check_box_outline_blank'
},
{
text: this.$strings.LabelDownloadSerie,
value: 'download_serie',
icon: 'download'
}
]
} else {
@ -122,9 +118,6 @@ export default {
} else if (action === 'collapse_subseries') {
this.settings.collapseBookSeries = !this.settings.collapseBookSeries
this.saveSettings()
} else if (action === 'download_serie') {
console.log('Download Serie click')
this.$eventBus.$emit('download-serie-click')
}
},
updateOrder() {
@ -152,6 +145,10 @@ export default {
async changeView() {
this.bookshelfListView = !this.bookshelfListView
await this.$hapticsImpact()
},
downloadSeries() {
console.log('Download Series click')
this.$eventBus.$emit('download-series-click')
}
},
mounted() {

View file

@ -28,8 +28,8 @@ export default {
mediaType: 'book',
booksPerFetch: 20,
books: 0,
numFiles: 0,
numAudioFiles: 0,
missingFiles: 0,
missingFilesSize: 0,
libraryIds: []
}
},
@ -40,7 +40,7 @@ export default {
}
},
methods: {
async downloadSerieClick() {
async downloadSeriesClick() {
console.log('Download Series clicked')
if (this.startingDownload) return
@ -60,7 +60,7 @@ export default {
searchParams.set('filter', `series.${this.$encode(this.seriesId)}`)
return searchParams.toString()
},
async fetchSerieEntities(page) {
async fetchSeriesEntities(page) {
const startIndex = page * this.booksPerFetch
this.currentSFQueryString = this.buildSearchParams()
@ -79,10 +79,9 @@ export default {
this.books = payload.total
for (let i = 0; i < payload.results.length; i++) {
console.log(payload.results[i].numFiles)
if (!(await this.$db.getLocalLibraryItem(`local_${payload.results[i].id}`))) {
this.numFiles += payload.results[i].numFiles
this.numAudioFiles += payload.results[i].media.numAudioFiles
this.missingFiles += payload.results[i].numFiles
this.missingFilesSize += payload.results[i].size
this.libraryIds.push(payload.results[i].id)
}
}
@ -124,32 +123,23 @@ export default {
}
}
// Fetch serie data from server
// Fetch series data from server
let page = 0
let fetchFinished = false
while (fetchFinished === false) {
fetchFinished = await this.fetchSerieEntities(page)
fetchFinished = await this.fetchSeriesEntities(page)
page += 1
}
if (fetchFinished !== true) {
console.error('failed to fetch serie books data')
console.error('failed to fetch series books data')
return null
}
// Format message for dialog
let startDownloadMessage = `Serie "${this.series.name}" has ${this.books} book${this.books == 1 ? '' : 's'}. Download missing ${this.libraryIds.length} book${this.libraryIds.length == 1 ? '' : 's'} with ${this.numFiles} file${this.numFiles == 1 ? '' : 's'}`
let numEbookFiles = this.numFiles - this.numAudioFiles
if (!this.isIos && numEbookFiles > 0) {
if (this.numAudioFiles > 0) {
startDownloadMessage = `Serie "${this.series.name}" has ${this.books} book${this.books == 1 ? '' : 's'}. Download missing ${this.libraryIds.length} book${this.libraryIds.length == 1 ? '' : 's'} with ${this.numAudioFiles} audio file${this.numAudioFiles == 1 ? '' : 's'} and ${numEbookFiles} ebook file${this.numEbookFiles == 1 ? '' : 's'}`
} else {
startDownloadMessage = `Serie "${this.series.name}" has ${this.books} book${this.books == 1 ? '' : 's'}. Download missing ${this.libraryIds.length} book${this.libraryIds.length == 1 ? '' : 's'} with ${this.numFiles} ebook file${this.numFiles == 1 ? '' : 's'}`
}
}
let startDownloadMessage = this.$getString('MessageSeriesDownloadConfirmIos', [this.libraryIds.length, this.missingFiles, this.$bytesPretty(this.missingFilesSize)])
if (!this.isIos) {
startDownloadMessage += ` to folder ${localFolder.name}`
startDownloadMessage = this.$getString('MessageSeriesDownloadConfirm', [this.libraryIds.length, this.missingFiles, this.$bytesPretty(this.missingFilesSize), localFolder.name])
}
startDownloadMessage += `?`
// Show confirmation dialog and start downloading if user chooses so
const { value } = await Dialog.confirm({
@ -180,10 +170,10 @@ export default {
}
},
mounted() {
this.$eventBus.$on('download-serie-click', this.downloadSerieClick)
this.$eventBus.$on('download-series-click', this.downloadSeriesClick)
},
beforeDestroy() {
this.$eventBus.$off('download-serie-click', this.downloadSerieClick)
this.$eventBus.$off('download-series-click', this.downloadSeriesClick)
}
}
</script>

View file

@ -123,7 +123,6 @@
"LabelDisableVibrateOnResetHelp": "When the sleep timer gets reset your device will vibrate. Enable this setting to not vibrate when the sleep timer resets.",
"LabelDiscover": "Discover",
"LabelDownload": "Download",
"LabelDownloadSerie": "Download serie",
"LabelDownloadUsingCellular": "Download using Cellular",
"LabelDownloaded": "Downloaded",
"LabelDuration": "Duration",
@ -288,6 +287,8 @@
"MessageNoUpdatesWereNecessary": "No updates were necessary",
"MessageNoUserPlaylists": "You have no playlists",
"MessageReportBugsAndContribute": "Report bugs, request features, and contribute on",
"MessageSeriesDownloadConfirm": "Download missing {0} book(s) with {1} file(s), totaling {2} to folder {3}?",
"MessageSeriesDownloadConfirmIos": "Download missing {0} book(s) with {1} file(s), totaling {2}?",
"MessageSocketConnectedOverMeteredCellular": "Socket connected over metered cellular",
"MessageSocketConnectedOverMeteredWifi": "Socket connected over metered wifi",
"MessageSocketConnectedOverUnmeteredCellular": "Socket connected over unmetered cellular",