Fix updating finished date on physical books throwing unsupported book type error (#2949)
This commit is contained in:
+30
-21
@@ -209,36 +209,45 @@ public class ReadingProgressService {
|
|||||||
progress.setBook(book);
|
progress.setBook(book);
|
||||||
progress.setLastReadTime(now);
|
progress.setLastReadTime(now);
|
||||||
|
|
||||||
Float percentage;
|
Float percentage = null;
|
||||||
|
|
||||||
if (request.getFileProgress() != null) {
|
boolean hasProgressData = request.getFileProgress() != null
|
||||||
BookFileProgress fileProgress = request.getFileProgress();
|
|| request.getEpubProgress() != null
|
||||||
percentage = fileProgress.progressPercent();
|
|| request.getPdfProgress() != null
|
||||||
|
|| request.getCbxProgress() != null
|
||||||
|
|| request.getAudiobookProgress() != null;
|
||||||
|
|
||||||
saveToUserBookFileProgress(userEntity, fileProgress, now);
|
if (hasProgressData) {
|
||||||
|
if (request.getFileProgress() != null) {
|
||||||
|
BookFileProgress fileProgress = request.getFileProgress();
|
||||||
|
percentage = fileProgress.progressPercent();
|
||||||
|
|
||||||
BookFileEntity bookFile = bookFileRepository.findById(fileProgress.bookFileId())
|
saveToUserBookFileProgress(userEntity, fileProgress, now);
|
||||||
.orElseThrow(() -> ApiError.GENERIC_NOT_FOUND.createException("Book file not found"));
|
|
||||||
updateProgressFromFileProgress(progress, bookFile.getBookType(), fileProgress);
|
BookFileEntity bookFile = bookFileRepository.findById(fileProgress.bookFileId())
|
||||||
} else {
|
.orElseThrow(() -> ApiError.GENERIC_NOT_FOUND.createException("Book file not found"));
|
||||||
BookFileEntity primaryFile = book.getPrimaryBookFile();
|
updateProgressFromFileProgress(progress, bookFile.getBookType(), fileProgress);
|
||||||
if (primaryFile == null) {
|
} else {
|
||||||
throw ApiError.UNSUPPORTED_BOOK_TYPE.createException();
|
BookFileEntity primaryFile = book.getPrimaryBookFile();
|
||||||
|
if (primaryFile == null) {
|
||||||
|
throw ApiError.UNSUPPORTED_BOOK_TYPE.createException();
|
||||||
|
}
|
||||||
|
percentage = updateProgressByBookType(progress, primaryFile.getBookType(), request);
|
||||||
|
|
||||||
|
if (percentage != null) {
|
||||||
|
saveToUserBookFileProgressFromLegacy(userEntity, primaryFile, progress, now);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
percentage = updateProgressByBookType(progress, primaryFile.getBookType(), request);
|
|
||||||
|
|
||||||
if (percentage != null) {
|
if (percentage != null) {
|
||||||
saveToUserBookFileProgressFromLegacy(userEntity, primaryFile, progress, now);
|
progress.setReadStatus(calculateReadStatus(percentage, progress.getReadStatus()));
|
||||||
|
BookFileEntity primaryFile = book.getPrimaryBookFile();
|
||||||
|
if (primaryFile != null) {
|
||||||
|
setProgressPercent(progress, primaryFile.getBookType(), percentage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (percentage != null) {
|
|
||||||
progress.setReadStatus(calculateReadStatus(percentage, progress.getReadStatus()));
|
|
||||||
BookFileEntity primaryFile = book.getPrimaryBookFile();
|
|
||||||
if (primaryFile != null) {
|
|
||||||
setProgressPercent(progress, primaryFile.getBookType(), percentage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (request.getDateFinished() != null) {
|
if (request.getDateFinished() != null) {
|
||||||
progress.setDateFinished(request.getDateFinished());
|
progress.setDateFinished(request.getDateFinished());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user