From 81c4424ae64476386447d93e2890f1424797356f Mon Sep 17 00:00:00 2001 From: Aditya Chandel <8075870+adityachandelgit@users.noreply.github.com> Date: Fri, 28 Nov 2025 15:05:23 -0700 Subject: [PATCH] =?UTF-8?q?Fix=20issue=20with=20=E2=80=9Cunset=E2=80=9D=20?= =?UTF-8?q?read=20status=20handling=20(#1669)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adityachandel/booklore/model/enums/ReadStatus.java | 3 ++- .../adityachandel/booklore/service/book/BookService.java | 9 ++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/model/enums/ReadStatus.java b/booklore-api/src/main/java/com/adityachandel/booklore/model/enums/ReadStatus.java index f4e2859d2..9866c8a54 100644 --- a/booklore-api/src/main/java/com/adityachandel/booklore/model/enums/ReadStatus.java +++ b/booklore-api/src/main/java/com/adityachandel/booklore/model/enums/ReadStatus.java @@ -8,5 +8,6 @@ public enum ReadStatus { PARTIALLY_READ, PAUSED, WONT_READ, - ABANDONED + ABANDONED, + UNSET } diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/service/book/BookService.java b/booklore-api/src/main/java/com/adityachandel/booklore/service/book/BookService.java index 602824a4c..9d44c077f 100644 --- a/booklore-api/src/main/java/com/adityachandel/booklore/service/book/BookService.java +++ b/booklore-api/src/main/java/com/adityachandel/booklore/service/book/BookService.java @@ -70,7 +70,7 @@ public class BookService { .percentage(progress.getKoboProgressPercent()) .build()); } - + switch (book.getBookType()) { case EPUB -> { book.setEpubProgress(EpubProgress.builder() @@ -96,7 +96,7 @@ public class BookService { if (progress != null) { setBookProgress(book, progress); 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()); } } @@ -187,7 +187,7 @@ public class BookService { .build()); } 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()); if (!withDescription) { @@ -408,7 +408,6 @@ public class BookService { progress.setBook(book); progress.setReadStatus(readStatus); - // Set dateFinished when status is READ, clear it otherwise if (readStatus == ReadStatus.READ) { progress.setDateFinished(Instant.now()); } else { @@ -430,7 +429,7 @@ public class BookService { if (progress != null) { setBookProgress(book, progress); 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()); }