mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-17 11:15:14 +00:00
Merge pull request #133 from SyncrowIOT/uniqe-scene-icon
remove duplicate in scene icons
This commit is contained in:
@ -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,
|
||||
|
Reference in New Issue
Block a user