mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-17 03:05:13 +00:00
Merge pull request #158 from SyncrowIOT/fix-get-scenes-by-space-issue
Update `getScene` method to accept `sceneUuid` and use it for spaceId
This commit is contained in:
@ -177,7 +177,7 @@ export class SceneService {
|
||||
space: { uuid: spaceUuid },
|
||||
...(showInHomePage ? { showInHomePage } : {}),
|
||||
},
|
||||
relations: ['sceneIcon'],
|
||||
relations: ['sceneIcon', 'space'],
|
||||
});
|
||||
|
||||
if (!scenesData.length) {
|
||||
@ -190,7 +190,10 @@ export class SceneService {
|
||||
const scenes = await Promise.all(
|
||||
scenesData.map(async (scene) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { actions, ...sceneDetails } = await this.getScene(scene);
|
||||
const { actions, ...sceneDetails } = await this.getScene(
|
||||
scene,
|
||||
spaceUuid,
|
||||
);
|
||||
|
||||
return sceneDetails;
|
||||
}),
|
||||
@ -376,7 +379,7 @@ export class SceneService {
|
||||
async getSceneByUuid(sceneUuid: string): Promise<BaseResponseDto> {
|
||||
try {
|
||||
const scene = await this.findScene(sceneUuid);
|
||||
const sceneDetails = await this.getScene(scene);
|
||||
const sceneDetails = await this.getScene(scene, sceneUuid);
|
||||
|
||||
return new SuccessResponseDto({
|
||||
data: sceneDetails,
|
||||
@ -399,7 +402,7 @@ export class SceneService {
|
||||
}
|
||||
}
|
||||
|
||||
async getScene(scene: SceneEntity): Promise<SceneDetails> {
|
||||
async getScene(scene: SceneEntity, sceneUuid: string): Promise<SceneDetails> {
|
||||
try {
|
||||
const { actions, name, status } = await this.fetchSceneDetailsFromTuya(
|
||||
scene.sceneTuyaUuid,
|
||||
@ -438,7 +441,7 @@ export class SceneService {
|
||||
showInHome: scene.showInHomePage,
|
||||
type: 'tap_to_run',
|
||||
actions,
|
||||
spaceId: scene.space.uuid,
|
||||
spaceId: sceneUuid,
|
||||
};
|
||||
} catch (err) {
|
||||
if (err instanceof BadRequestException) {
|
||||
@ -478,7 +481,7 @@ export class SceneService {
|
||||
async findScene(sceneUuid: string): Promise<SceneEntity> {
|
||||
const scene = await this.sceneRepository.findOne({
|
||||
where: { uuid: sceneUuid },
|
||||
relations: ['sceneIcon'],
|
||||
relations: ['sceneIcon', 'space'],
|
||||
});
|
||||
|
||||
if (!scene) {
|
||||
|
Reference in New Issue
Block a user