PR fixes and tested

This commit is contained in:
raf-dev1
2025-06-18 08:42:18 +03:00
parent 09f2123946
commit 1ba1aba54e

View File

@ -1457,27 +1457,21 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
List<ScenesModel> changeItemStateOnToggelingSceen( List<ScenesModel> changeItemStateOnToggelingSceen(
List<ScenesModel> oldSceen, String automationId) { List<ScenesModel> oldSceen, String automationId) {
final updatedAutomations = oldSceen; return oldSceen.map((scene) {
final temp = if (scene.id == automationId) {
updatedAutomations.firstWhere((element) => element.id == automationId); return ScenesModel(
final tempIndex = updatedAutomations.indexWhere( id: scene.id,
(element) => element.id == automationId, sceneTuyaId: scene.sceneTuyaId,
name: scene.name,
status: scene.status == 'enable' ? 'disable' : 'enable',
type: scene.type,
spaceName: scene.spaceName,
spaceId: scene.spaceId,
communityId: scene.communityId,
icon: scene.icon,
); );
updatedAutomations.removeWhere( }
(element) => element.id == automationId, return scene;
); }).toList();
updatedAutomations.insert(
tempIndex,
ScenesModel(
id: temp.id,
name: temp.name,
status: temp.status == 'enable' ? 'disable' : 'enable',
type: temp.type,
spaceName: temp.spaceName,
spaceId: temp.spaceId,
communityId: temp.communityId,
),
);
return updatedAutomations;
} }
} }