mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
PR fixes and tested
This commit is contained in:
@ -1457,27 +1457,21 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
|
||||
|
||||
List<ScenesModel> changeItemStateOnToggelingSceen(
|
||||
List<ScenesModel> oldSceen, String automationId) {
|
||||
final updatedAutomations = oldSceen;
|
||||
final temp =
|
||||
updatedAutomations.firstWhere((element) => element.id == automationId);
|
||||
final tempIndex = updatedAutomations.indexWhere(
|
||||
(element) => element.id == automationId,
|
||||
);
|
||||
updatedAutomations.removeWhere(
|
||||
(element) => element.id == automationId,
|
||||
);
|
||||
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;
|
||||
return oldSceen.map((scene) {
|
||||
if (scene.id == automationId) {
|
||||
return ScenesModel(
|
||||
id: scene.id,
|
||||
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,
|
||||
);
|
||||
}
|
||||
return scene;
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user