diff --git a/backend/endpoints/collections.py b/backend/endpoints/collections.py index af1d24c2f..c57e0dd4d 100644 --- a/backend/endpoints/collections.py +++ b/backend/endpoints/collections.py @@ -117,6 +117,8 @@ def get_collections( @protected_route(router.get, "/collections/virtual", [Scope.COLLECTIONS_READ]) def get_virtual_collections( request: Request, + type: str, + limit: int | None = None, ) -> list[VirtualCollectionSchema]: """Get virtual collections endpoint @@ -127,7 +129,7 @@ def get_virtual_collections( list[VirtualCollectionSchema]: List of virtual collections """ - virtual_collections = db_collection_handler.get_virtual_collections() + virtual_collections = db_collection_handler.get_virtual_collections(type, limit) return [VirtualCollectionSchema.model_validate(vc) for vc in virtual_collections] diff --git a/backend/handler/database/collections_handler.py b/backend/handler/database/collections_handler.py index 0216161c1..1ab82210b 100644 --- a/backend/handler/database/collections_handler.py +++ b/backend/handler/database/collections_handler.py @@ -51,12 +51,13 @@ class DBCollectionsHandler(DBBaseHandler): @begin_session def get_virtual_collections( - self, session: Session = None + self, type: str, limit: int | None = None, session: Session = None ) -> Sequence[VirtualCollection]: return ( session.scalars( select(VirtualCollection) - .filter(VirtualCollection.type.in_(["collection"])) + .filter(VirtualCollection.type.in_([type])) + .limit(limit) .order_by(VirtualCollection.name.asc()) ) .unique() diff --git a/frontend/src/components/Settings/UserInterface/Interface.vue b/frontend/src/components/Settings/UserInterface/Interface.vue index 3d9d4fca0..28b4bd6a4 100644 --- a/frontend/src/components/Settings/UserInterface/Interface.vue +++ b/frontend/src/components/Settings/UserInterface/Interface.vue @@ -1,12 +1,16 @@ diff --git a/frontend/src/services/api/collection.ts b/frontend/src/services/api/collection.ts index d3d942424..1c4cd6d3f 100644 --- a/frontend/src/services/api/collection.ts +++ b/frontend/src/services/api/collection.ts @@ -27,8 +27,14 @@ async function getCollections(): Promise<{ data: Collection[] }> { return api.get("/collections"); } -async function getVirtualCollections(): Promise<{ data: VirtualCollection[] }> { - return api.get("/collections/virtual"); +async function getVirtualCollections({ + type = "collection", + limit = 100, +}: { + type?: string; + limit?: number; +}): Promise<{ data: VirtualCollection[] }> { + return api.get("/collections/virtual", { params: { type, limit } }); } async function getCollection(id: number): Promise<{ data: Collection }> { diff --git a/frontend/src/views/Home.vue b/frontend/src/views/Home.vue index 528808d1e..1b8ba0503 100644 --- a/frontend/src/views/Home.vue +++ b/frontend/src/views/Home.vue @@ -38,6 +38,11 @@ const showPlatforms = isNull(localStorage.getItem("settings.showPlatforms")) const showCollections = isNull(localStorage.getItem("settings.showCollections")) ? true : localStorage.getItem("settings.showCollections") === "true"; +const showVirtualCollections = isNull( + localStorage.getItem("settings.showVirtualCollections"), +) + ? true + : localStorage.getItem("settings.showVirtualCollections") === "true"; const fetchingRecentAdded = ref(false); const fetchingContinuePlaying = ref(false); @@ -95,6 +100,6 @@ onMounted(async () => {