fix: reset audiobook progress and clear cached progress in UI (#2641) (#2711)

This commit is contained in:
ACX
2026-02-12 08:21:05 -07:00
committed by GitHub
parent 120334eb28
commit f8f448a19b
3 changed files with 19 additions and 1 deletions

View File

@@ -6,6 +6,8 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.data.jpa.repository.Modifying;
import java.util.List;
import java.util.Optional;
@@ -58,4 +60,12 @@ public interface UserBookFileProgressRepository extends JpaRepository<UserBookFi
@Param("userId") Long userId,
@Param("bookIds") Iterable<Long> bookIds
);
@Modifying
@Query("""
DELETE FROM UserBookFileProgressEntity ubfp
WHERE ubfp.user.id = :userId
AND ubfp.bookFile.book.id IN :bookIds
""")
int deleteByUserIdAndBookIds(@Param("userId") Long userId, @Param("bookIds") Iterable<Long> bookIds);
}

View File

@@ -431,7 +431,10 @@ public class ReadingProgressService {
List<Long> bookIdList = new ArrayList<>(bookIds);
switch (type) {
case BOOKLORE -> userBookProgressRepository.bulkResetBookloreProgress(userId, bookIdList, now);
case BOOKLORE -> {
userBookProgressRepository.bulkResetBookloreProgress(userId, bookIdList, now);
userBookFileProgressRepository.deleteByUserIdAndBookIds(userId, bookIdList);
}
case KOREADER -> userBookProgressRepository.bulkResetKoreaderProgress(userId, bookIdList);
case KOBO -> {
userBookProgressRepository.bulkResetKoboProgress(userId, bookIdList);

View File

@@ -163,8 +163,13 @@ export class BookPatchService {
const updatedBooks = (currentState.books || []).map(book => {
const response = responses.find(r => r.bookId === book.id);
if (response) {
const progressReset: Partial<Book> =
type === 'KOREADER' ? {koreaderProgress: undefined} :
type === 'KOBO' ? {koboProgress: undefined} :
{epubProgress: undefined, pdfProgress: undefined, cbxProgress: undefined, audiobookProgress: undefined};
return {
...book,
...progressReset,
readStatus: response.readStatus,
readStatusModifiedTime: response.readStatusModifiedTime,
dateFinished: response.dateFinished