Fix issue with “unset” read status handling (#1669)

This commit is contained in:
Aditya Chandel
2025-11-28 15:05:23 -07:00
committed by GitHub
parent 3a9cb965e3
commit 81c4424ae6
2 changed files with 6 additions and 6 deletions
@@ -8,5 +8,6 @@ public enum ReadStatus {
PARTIALLY_READ, PARTIALLY_READ,
PAUSED, PAUSED,
WONT_READ, WONT_READ,
ABANDONED ABANDONED,
UNSET
} }
@@ -70,7 +70,7 @@ public class BookService {
.percentage(progress.getKoboProgressPercent()) .percentage(progress.getKoboProgressPercent())
.build()); .build());
} }
switch (book.getBookType()) { switch (book.getBookType()) {
case EPUB -> { case EPUB -> {
book.setEpubProgress(EpubProgress.builder() book.setEpubProgress(EpubProgress.builder()
@@ -96,7 +96,7 @@ public class BookService {
if (progress != null) { if (progress != null) {
setBookProgress(book, progress); setBookProgress(book, progress);
book.setLastReadTime(progress.getLastReadTime()); book.setLastReadTime(progress.getLastReadTime());
book.setReadStatus(String.valueOf(progress.getReadStatus())); book.setReadStatus(progress.getReadStatus() == null ? String.valueOf(ReadStatus.UNSET) : String.valueOf(progress.getReadStatus()));
book.setDateFinished(progress.getDateFinished()); book.setDateFinished(progress.getDateFinished());
} }
} }
@@ -187,7 +187,7 @@ public class BookService {
.build()); .build());
} }
book.setFilePath(FileUtils.getBookFullPath(bookEntity)); book.setFilePath(FileUtils.getBookFullPath(bookEntity));
book.setReadStatus(String.valueOf(userProgress.getReadStatus())); book.setReadStatus(userProgress.getReadStatus() == null ? String.valueOf(ReadStatus.UNSET) : String.valueOf(userProgress.getReadStatus()));
book.setDateFinished(userProgress.getDateFinished()); book.setDateFinished(userProgress.getDateFinished());
if (!withDescription) { if (!withDescription) {
@@ -408,7 +408,6 @@ public class BookService {
progress.setBook(book); progress.setBook(book);
progress.setReadStatus(readStatus); progress.setReadStatus(readStatus);
// Set dateFinished when status is READ, clear it otherwise
if (readStatus == ReadStatus.READ) { if (readStatus == ReadStatus.READ) {
progress.setDateFinished(Instant.now()); progress.setDateFinished(Instant.now());
} else { } else {
@@ -430,7 +429,7 @@ public class BookService {
if (progress != null) { if (progress != null) {
setBookProgress(book, progress); setBookProgress(book, progress);
book.setLastReadTime(progress.getLastReadTime()); book.setLastReadTime(progress.getLastReadTime());
book.setReadStatus(String.valueOf(progress.getReadStatus())); book.setReadStatus(progress.getReadStatus() == null ? String.valueOf(ReadStatus.UNSET) : String.valueOf(progress.getReadStatus()));
book.setDateFinished(progress.getDateFinished()); book.setDateFinished(progress.getDateFinished());
} }