fix: space overview favorites (#2110)

This commit is contained in:
Philip Okugbe
2026-04-14 02:58:24 +01:00
committed by GitHub
parent 66c70c0e76
commit cc00e77dfb
11 changed files with 103 additions and 39 deletions
@@ -1,8 +1,12 @@
import { IsIn, IsNotEmpty, IsString } from 'class-validator';
import { IsIn, IsNotEmpty, IsOptional, IsString, IsUUID } from 'class-validator';
export class FavoriteIdsDto {
@IsString()
@IsNotEmpty()
@IsIn(['page', 'space', 'template'])
type: 'page' | 'space' | 'template';
@IsOptional()
@IsUUID()
spaceId?: string;
}
@@ -1,8 +1,12 @@
import { IsIn, IsOptional, IsString } from 'class-validator';
import { IsIn, IsOptional, IsString, IsUUID } from 'class-validator';
export class ListFavoritesDto {
@IsOptional()
@IsString()
@IsIn(['page', 'space', 'template'])
type?: 'page' | 'space' | 'template';
@IsOptional()
@IsUUID()
spaceId?: string;
}
@@ -82,6 +82,7 @@ export class FavoriteController {
user.id,
workspace.id,
dto.type as FavoriteType,
dto.spaceId,
);
}
@@ -98,6 +99,7 @@ export class FavoriteController {
workspace.id,
pagination,
dto.type as FavoriteType | undefined,
dto.spaceId,
);
}
@@ -20,11 +20,13 @@ export class FavoriteService {
userId: string,
workspaceId: string,
type: FavoriteType,
spaceId?: string,
) {
const result = await this.favoriteRepo.getFavoriteIds(
userId,
workspaceId,
type,
spaceId,
);
if (result.items.length === 0) {
@@ -95,12 +97,14 @@ export class FavoriteService {
workspaceId: string,
pagination: PaginationOptions,
type?: FavoriteType,
spaceId?: string,
) {
const result = await this.favoriteRepo.findUserFavorites(
userId,
workspaceId,
pagination,
type,
spaceId,
);
if (result.items.length === 0) {