refactor: remove unused property number in BookPageContent

This commit is contained in:
Gauthier Roebroeck 2023-09-05 14:23:37 +08:00
parent 37e7d55fbe
commit cb5177db52
3 changed files with 5 additions and 6 deletions

View File

@ -1,7 +1,6 @@
package org.gotson.komga.domain.model
class BookPageContent(
val number: Int,
val content: ByteArray,
val mediaType: String,
)

View File

@ -239,7 +239,7 @@ class BookLifecycle(
)
fun getBookPage(book: Book, number: Int, convertTo: ImageType? = null, resizeTo: Int? = null): BookPageContent {
val media = mediaRepository.findById(book.id)
val pageContent = bookAnalyzer.getPageContent(BookWithMedia(book, mediaRepository.findById(book.id)), number)
val pageContent = bookAnalyzer.getPageContent(BookWithMedia(book, media), number)
val pageMediaType = media.pages[number - 1].mediaType
if (resizeTo != null) {
@ -249,7 +249,7 @@ class BookLifecycle(
logger.error(e) { "Resize page #$number of book $book to $resizeTo: failed" }
throw e
}
return BookPageContent(number, convertedPage, resizeTargetFormat.mediaType)
return BookPageContent(convertedPage, resizeTargetFormat.mediaType)
} else {
convertTo?.let {
val msg = "Convert page #$number of book $book from $pageMediaType to ${it.mediaType}"
@ -271,10 +271,10 @@ class BookLifecycle(
logger.error(e) { "$msg: conversion failed" }
throw e
}
return BookPageContent(number, convertedPage, it.mediaType)
return BookPageContent(convertedPage, it.mediaType)
}
return BookPageContent(number, pageContent, pageMediaType)
return BookPageContent(pageContent, pageMediaType)
}
}

View File

@ -49,6 +49,6 @@ class TransientBookLifecycle(
val pageContent = bookAnalyzer.getPageContent(transientBook, number)
val pageMediaType = transientBook.media.pages[number - 1].mediaType
return BookPageContent(number, pageContent, pageMediaType)
return BookPageContent(pageContent, pageMediaType)
}
}