diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/model/dto/Shelf.java b/booklore-api/src/main/java/com/adityachandel/booklore/model/dto/Shelf.java
index f307aaf4f..4a61f232c 100644
--- a/booklore-api/src/main/java/com/adityachandel/booklore/model/dto/Shelf.java
+++ b/booklore-api/src/main/java/com/adityachandel/booklore/model/dto/Shelf.java
@@ -12,4 +12,5 @@ public class Shelf {
private String name;
private String icon;
private Sort sort;
+ private Long userId;
}
diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/service/BookQueryService.java b/booklore-api/src/main/java/com/adityachandel/booklore/service/BookQueryService.java
index 58a995f9b..aac565f65 100644
--- a/booklore-api/src/main/java/com/adityachandel/booklore/service/BookQueryService.java
+++ b/booklore-api/src/main/java/com/adityachandel/booklore/service/BookQueryService.java
@@ -11,8 +11,6 @@ import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import java.util.List;
@@ -28,88 +26,36 @@ public class BookQueryService {
public List getAllBooks(boolean includeDescription) {
List books = bookRepository.findAllWithMetadata();
- return books.stream()
- .map(book -> {
- Book dto = bookMapperV2.toDTO(book);
- if (!includeDescription && dto.getMetadata() != null) {
- dto.getMetadata().setDescription(null);
- }
- return dto;
- })
- .collect(Collectors.toList());
+ return mapBooksToDto(books, includeDescription, null);
}
public Page getAllBooksPage(boolean includeDescription, int page, int size) {
Pageable pageable = PageRequest.of(Math.max(page - 1, 0), size);
Page books = bookRepository.findAllWithMetadata(pageable);
- List mapped = books.getContent().stream()
- .map(book -> {
- Book dto = bookMapperV2.toDTO(book);
- if (!includeDescription && dto.getMetadata() != null) {
- dto.getMetadata().setDescription(null);
- }
- return dto;
- })
- .collect(Collectors.toList());
- return new PageImpl<>(mapped, pageable, books.getTotalElements());
+ return createPageFromBooks(books, pageable, includeDescription, null);
}
public Page getRecentBooksPage(boolean includeDescription, int page, int size) {
Pageable pageable = PageRequest.of(Math.max(page - 1, 0), size, Sort.by("addedOn").descending());
Page books = bookRepository.findAllWithMetadata(pageable);
- List mapped = books.getContent().stream()
- .map(book -> {
- Book dto = bookMapperV2.toDTO(book);
- if (!includeDescription && dto.getMetadata() != null) {
- dto.getMetadata().setDescription(null);
- }
- return dto;
- })
- .collect(Collectors.toList());
- return new PageImpl<>(mapped, pageable, books.getTotalElements());
+ return createPageFromBooks(books, pageable, includeDescription, null);
}
- public List getAllBooksByLibraryIds(Set libraryIds, boolean includeDescription) {
+ public List getAllBooksByLibraryIds(Set libraryIds, boolean includeDescription, Long userId) {
List books = bookRepository.findAllWithMetadataByLibraryIds(libraryIds);
- return books.stream()
- .map(book -> {
- Book dto = bookMapperV2.toDTO(book);
- if (!includeDescription && dto.getMetadata() != null) {
- dto.getMetadata().setDescription(null);
- }
- return dto;
- })
- .collect(Collectors.toList());
+ return mapBooksToDto(books, includeDescription, userId);
}
- public Page getAllBooksByLibraryIdsPage(Set libraryIds, boolean includeDescription, int page, int size) {
+ public Page getAllBooksByLibraryIdsPage(Set libraryIds, boolean includeDescription, int page, int size, Long userId) {
Pageable pageable = PageRequest.of(Math.max(page - 1, 0), size);
Page books = bookRepository.findAllWithMetadataByLibraryIds(libraryIds, pageable);
- List mapped = books.getContent().stream()
- .map(book -> {
- Book dto = bookMapperV2.toDTO(book);
- if (!includeDescription && dto.getMetadata() != null) {
- dto.getMetadata().setDescription(null);
- }
- return dto;
- })
- .collect(Collectors.toList());
- return new PageImpl<>(mapped, pageable, books.getTotalElements());
+ return createPageFromBooks(books, pageable, includeDescription, userId);
}
- public Page getRecentBooksByLibraryIdsPage(Set libraryIds, boolean includeDescription, int page, int size) {
+ public Page getRecentBooksByLibraryIdsPage(Set libraryIds, boolean includeDescription, int page, int size, Long userId) {
Pageable pageable = PageRequest.of(Math.max(page - 1, 0), size, Sort.by("addedOn").descending());
Page books = bookRepository.findAllWithMetadataByLibraryIds(libraryIds, pageable);
- List mapped = books.getContent().stream()
- .map(book -> {
- Book dto = bookMapperV2.toDTO(book);
- if (!includeDescription && dto.getMetadata() != null) {
- dto.getMetadata().setDescription(null);
- }
- return dto;
- })
- .collect(Collectors.toList());
- return new PageImpl<>(mapped, pageable, books.getTotalElements());
+ return createPageFromBooks(books, pageable, includeDescription, userId);
}
public List findAllWithMetadataByIds(Set bookIds) {
@@ -160,21 +106,37 @@ public class BookQueryService {
public Page getAllBooksByShelfPage(Long shelfId, boolean includeDescription, int page, int size) {
Pageable pageable = PageRequest.of(Math.max(page - 1, 0), size);
Page books = bookRepository.findAllWithMetadataByShelfId(shelfId, pageable);
- List mapped = books.getContent().stream()
- .map(book -> {
- Book dto = bookMapperV2.toDTO(book);
- if (!includeDescription && dto.getMetadata() != null) {
- dto.getMetadata().setDescription(null);
- }
- return dto;
- })
- .collect(Collectors.toList());
- return new PageImpl<>(mapped, pageable, books.getTotalElements());
+ return createPageFromBooks(books, pageable, includeDescription, null);
}
public void saveAll(List books) {
bookRepository.saveAll(books);
}
- // Removed OPDS Magic Shelves support
+ private List mapBooksToDto(List books, boolean includeDescription, Long userId) {
+ return books.stream()
+ .map(book -> mapBookToDto(book, includeDescription, userId))
+ .collect(Collectors.toList());
+ }
+
+ private Book mapBookToDto(BookEntity bookEntity, boolean includeDescription, Long userId) {
+ Book dto = bookMapperV2.toDTO(bookEntity);
+
+ if (!includeDescription && dto.getMetadata() != null) {
+ dto.getMetadata().setDescription(null);
+ }
+
+ if (dto.getShelves() != null && userId != null) {
+ dto.setShelves(dto.getShelves().stream()
+ .filter(shelf -> userId.equals(shelf.getUserId()))
+ .collect(Collectors.toSet()));
+ }
+
+ return dto;
+ }
+
+ private Page createPageFromBooks(Page books, Pageable pageable, boolean includeDescription, Long userId) {
+ List mapped = mapBooksToDto(books.getContent(), includeDescription, userId);
+ return new PageImpl<>(mapped, pageable, books.getTotalElements());
+ }
}
diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/service/BookService.java b/booklore-api/src/main/java/com/adityachandel/booklore/service/BookService.java
index 4b6a14aa5..f9def8a79 100644
--- a/booklore-api/src/main/java/com/adityachandel/booklore/service/BookService.java
+++ b/booklore-api/src/main/java/com/adityachandel/booklore/service/BookService.java
@@ -103,7 +103,8 @@ public class BookService {
user.getAssignedLibraries().stream()
.map(Library::getId)
.collect(Collectors.toSet()),
- includeDescription
+ includeDescription,
+ user.getId()
);
Map progressMap =
diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/service/KoreaderService.java b/booklore-api/src/main/java/com/adityachandel/booklore/service/KoreaderService.java
index e3e1e12d1..5bae3b158 100644
--- a/booklore-api/src/main/java/com/adityachandel/booklore/service/KoreaderService.java
+++ b/booklore-api/src/main/java/com/adityachandel/booklore/service/KoreaderService.java
@@ -34,40 +34,24 @@ public class KoreaderService {
private final UserRepository userRepository;
private final KoreaderUserRepository koreaderUserRepository;
- private KoreaderUserDetails getAuthDetails() {
- Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
- if (!(principal instanceof KoreaderUserDetails details)) {
- log.warn("Authentication failed: invalid principal type");
- throw ApiError.GENERIC_UNAUTHORIZED.createException("User not authenticated");
- }
- return details;
- }
-
public ResponseEntity
@@ -120,4 +123,4 @@
Loading series details...
-}
\ No newline at end of file
+}
diff --git a/booklore-ui/src/app/book/components/series-page/series-page.component.ts b/booklore-ui/src/app/book/components/series-page/series-page.component.ts
index dbca831d4..543f839e3 100644
--- a/booklore-ui/src/app/book/components/series-page/series-page.component.ts
+++ b/booklore-ui/src/app/book/components/series-page/series-page.component.ts
@@ -127,6 +127,13 @@ export class SeriesPageComponent {
const allRead = statuses.every((s) => s === ReadStatus.READ);
if (allRead) return ReadStatus.READ;
+ // If any book is currently being read, surface series status as READING
+ const isAnyReading = statuses.some(
+ (s) => s === ReadStatus.READING || s === ReadStatus.RE_READING || s === ReadStatus.PAUSED
+ );
+ if (isAnyReading) return ReadStatus.READING;
+
+ // If some are read and some are unread, surface as PARTIALLY_READ
const someRead = statuses.some((s) => s === ReadStatus.READ);
if (someRead) return ReadStatus.PARTIALLY_READ;
@@ -137,6 +144,15 @@ export class SeriesPageComponent {
})
);
+ // Progress like "12/20" (read/total)
+ seriesReadProgress$: Observable = this.filteredBooks$.pipe(
+ map((books) => {
+ const total = books?.length ?? 0;
+ const readCount = (books || []).filter((b) => b.readStatus === ReadStatus.READ).length;
+ return `${readCount}/${total}`;
+ })
+ );
+
get currentCardSize() {
return this.coverScalePreferenceService.currentCardSize;
}
@@ -193,10 +209,16 @@ export class SeriesPageComponent {
switch (v) {
case ReadStatus.UNREAD:
return 'UNREAD';
+ case ReadStatus.READING:
+ return 'READING';
+ case ReadStatus.RE_READING:
+ return 'RE-READING';
case ReadStatus.READ:
return 'READ';
case ReadStatus.PARTIALLY_READ:
return 'PARTIALLY READ';
+ case ReadStatus.PAUSED:
+ return 'PAUSED';
case ReadStatus.ABANDONED:
return 'ABANDONED';
case ReadStatus.WONT_READ:
@@ -211,10 +233,17 @@ export class SeriesPageComponent {
switch (normalized) {
case "UNREAD":
return "bg-gray-500";
+ case "READING":
+ return "bg-blue-600";
case "READ":
return "bg-green-600";
case "PARTIALLY_READ":
return "bg-yellow-600";
+ case "PAUSED":
+ return "bg-slate-600";
+ case "RE-READING":
+ case "RE_READING":
+ return "bg-purple-600";
case "ABANDONED":
return "bg-red-600";
case "WONT_READ":
diff --git a/booklore-ui/src/app/metadata/book-metadata-center-component/metadata-viewer/metadata-viewer.component.ts b/booklore-ui/src/app/metadata/book-metadata-center-component/metadata-viewer/metadata-viewer.component.ts
index 90401dab9..f707ba3d2 100644
--- a/booklore-ui/src/app/metadata/book-metadata-center-component/metadata-viewer/metadata-viewer.component.ts
+++ b/booklore-ui/src/app/metadata/book-metadata-center-component/metadata-viewer/metadata-viewer.component.ts
@@ -543,7 +543,8 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
}
goToSeries(seriesName: string): void {
- this.router.navigate(['/series', seriesName]);
+ const encodedSeriesName = encodeURIComponent(seriesName);
+ this.router.navigate(['/series', encodedSeriesName]);
}
goToPublisher(publisher: string): void {