mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-17 03:05:13 +00:00
On empty list, return empty array. Instead of error
This commit is contained in:
@ -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) {
|
||||||
|
@ -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(
|
||||||
|
@ -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({
|
||||||
|
Reference in New Issue
Block a user