On empty list, return empty array. Instead of error

This commit is contained in:
hannathkadher
2024-11-07 10:41:54 +04:00
parent 2edf65ab07
commit af6aefca9c
3 changed files with 3 additions and 11 deletions

View File

@ -14,8 +14,6 @@ export class SceneIconSeeder {
}); });
if (defaultSceneIconData.length <= 0) { if (defaultSceneIconData.length <= 0) {
console.log('Creating default scene icon...');
await this.createDefaultSceneIcon(); await this.createDefaultSceneIcon();
} }
} catch (err) { } catch (err) {

View File

@ -178,10 +178,7 @@ export class SceneService {
}); });
if (!scenesData.length) { if (!scenesData.length) {
throw new HttpException( return [];
`No scenes found for space UUID ${spaceUuid} with showInHomePage ${showInHomePage} `,
HttpStatus.NOT_FOUND,
);
} }
const scenes = await Promise.all( const scenes = await Promise.all(

View File

@ -18,16 +18,13 @@ export class UserSpaceService {
) {} ) {}
async getSpacesForUser(userUuid: string): Promise<BaseResponseDto> { async getSpacesForUser(userUuid: string): Promise<BaseResponseDto> {
const userSpaces = await this.userSpaceRepository.find({ let userSpaces = await this.userSpaceRepository.find({
where: { user: { uuid: userUuid } }, where: { user: { uuid: userUuid } },
relations: ['space', 'space.community'], relations: ['space', 'space.community'],
}); });
if (!userSpaces || userSpaces.length === 0) { if (!userSpaces || userSpaces.length === 0) {
throw new HttpException( userSpaces = [];
`No spaces found for user with ID ${userUuid}`,
HttpStatus.NOT_FOUND,
);
} }
return new SuccessResponseDto({ return new SuccessResponseDto({