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,
updatedAutomations.removeWhere( status: scene.status == 'enable' ? 'disable' : 'enable',
(element) => element.id == automationId, type: scene.type,
); spaceName: scene.spaceName,
updatedAutomations.insert( spaceId: scene.spaceId,
tempIndex, communityId: scene.communityId,
ScenesModel( icon: scene.icon,
id: temp.id, );
name: temp.name, }
status: temp.status == 'enable' ? 'disable' : 'enable', return scene;
type: temp.type, }).toList();
spaceName: temp.spaceName,
spaceId: temp.spaceId,
communityId: temp.communityId,
),
);
return updatedAutomations;
} }
} }