Merge pull request #133 from SyncrowIOT/uniqe-scene-icon

remove duplicate in scene icons
This commit is contained in:
faris Aljohari
2024-10-30 19:44:49 -05:00
committed by GitHub

View File

@ -426,10 +426,18 @@ export class SceneService {
}
async getAllIcons() {
try {
const icons = await this.sceneIconRepository.find();
return icons;
const icons = await this.sceneIconRepository.find({
where: { iconType: SceneIconType.Other },
});
// Remove duplicates based on 'icon' property
const uniqueIcons = icons.filter(
(icon, index, self) =>
index === self.findIndex((t) => t.icon === icon.icon),
);
return uniqueIcons;
} catch (err) {
// Improved error handling
throw new HttpException(
{
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,