diff --git a/client/src/features/collection/components/EditCollectionDialog.vue b/client/src/features/collection/components/EditCollectionDialog.vue
index 89d0ffa9a..5f0eff747 100644
--- a/client/src/features/collection/components/EditCollectionDialog.vue
+++ b/client/src/features/collection/components/EditCollectionDialog.vue
@@ -83,7 +83,7 @@ async function handleDelete() {
-
+
diff --git a/client/src/features/lens/components/CreateLensDialog.vue b/client/src/features/lens/components/CreateLensDialog.vue
index 17fa83d91..8f67f8601 100644
--- a/client/src/features/lens/components/CreateLensDialog.vue
+++ b/client/src/features/lens/components/CreateLensDialog.vue
@@ -66,7 +66,7 @@ async function submit() {
-
+
diff --git a/server/src/modules/collection/collection.service.test.ts b/server/src/modules/collection/collection.service.test.ts
index cd627f9c6..528693f76 100644
--- a/server/src/modules/collection/collection.service.test.ts
+++ b/server/src/modules/collection/collection.service.test.ts
@@ -121,6 +121,38 @@ describe('CollectionService', () => {
});
});
+ describe('update', () => {
+ it('returns the hydrated collection so derived counts remain available', async () => {
+ const { service, collectionRepo } = makeService();
+ const existing = makeCollection({ bookCount: 3 });
+ const hydrated = makeCollection({ name: 'Updated Favorites', icon: 'FolderHeart', syncToKobo: true, bookCount: 3 });
+ collectionRepo.findById.mockResolvedValueOnce([existing]).mockResolvedValueOnce([hydrated]);
+ collectionRepo.update.mockResolvedValue([
+ {
+ id: existing.id,
+ userId: existing.userId,
+ name: 'Updated Favorites',
+ icon: 'FolderHeart',
+ description: existing.description,
+ syncToKobo: true,
+ displayOrder: existing.displayOrder,
+ createdAt: existing.createdAt,
+ updatedAt: existing.updatedAt,
+ },
+ ]);
+
+ const result = await service.update(existing.id, { name: 'Updated Favorites', icon: 'FolderHeart', syncToKobo: true }, makeUser());
+
+ expect(collectionRepo.update).toHaveBeenCalledWith(existing.id, existing.userId, {
+ name: 'Updated Favorites',
+ icon: 'FolderHeart',
+ syncToKobo: true,
+ });
+ expect(collectionRepo.findById).toHaveBeenCalledTimes(2);
+ expect(result).toEqual(hydrated);
+ });
+ });
+
describe('addBooks', () => {
it('verifies collection ownership and library access before adding books', async () => {
const { service, collectionRepo, bookReadService, libraryService } = makeService();
diff --git a/server/src/modules/collection/collection.service.ts b/server/src/modules/collection/collection.service.ts
index 0f15b6d31..ab5d1ebfa 100644
--- a/server/src/modules/collection/collection.service.ts
+++ b/server/src/modules/collection/collection.service.ts
@@ -85,12 +85,14 @@ export class CollectionService {
async update(id: number, dto: UpdateCollectionDto, user: RequestUser) {
const existing = await this.findCollectionForUserOrThrow(id, user);
- const [updated] = await this.collectionRepo.update(id, existing.userId, {
+ await this.collectionRepo.update(id, existing.userId, {
...(dto.name !== undefined && { name: dto.name }),
...(dto.icon !== undefined && { icon: dto.icon.trim() || null }),
...(dto.description !== undefined && { description: dto.description }),
...(dto.syncToKobo !== undefined && { syncToKobo: dto.syncToKobo }),
});
+
+ const [updated] = await this.collectionRepo.findById(id);
return updated;
}