mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
bug fixed it is locally change the state now (#264)
<!-- Thanks for contributing! Provide a description of your changes below and a general summary in the title Please look at the following checklist to ensure that your PR can be accepted quickly: --> ## Jira Ticket [SP-SP-1413](https://syncrow.atlassian.net/jira/software/projects/SP/boards/5?assignee=712020%3A71e88a7f-7752-44b3-8177-4ab51a950811&selectedIssue=SP-1413) ## Description state now changes without fetching API it is locallly ## Type of Change <!--- Put an `x` in all the boxes that apply: --> - [ ] ✨ New feature (non-breaking change which adds functionality) - [x] 🛠️ Bug fix (non-breaking change which fixes an issue) - [ ] ❌ Breaking change (fix or feature that would cause existing functionality to change) - [ ] 🧹 Code refactor - [ ] ✅ Build configuration change - [ ] 📝 Documentation - [ ] 🗑️ Chore
This commit is contained in:
@ -1419,15 +1419,17 @@ Future<void> _onLoadScenes(
|
||||
event.automationId, event.automationStatusUpdate, projectId);
|
||||
|
||||
if (success) {
|
||||
final updatedAutomations = await SceneApi.getAutomationByUnitId(
|
||||
event.automationStatusUpdate.spaceUuid,
|
||||
event.communityId,
|
||||
projectId);
|
||||
// await SceneApi.getAutomationByUnitId(
|
||||
// event.automationStatusUpdate.spaceUuid,
|
||||
// event.communityId,
|
||||
// projectId);
|
||||
|
||||
// Remove from loading set safely
|
||||
|
||||
final updatedLoadingIds = {...state.loadingAutomationIds!}
|
||||
..remove(event.automationId);
|
||||
|
||||
final updatedAutomations = changeItemStateOnToggelingSceen(
|
||||
state.automations, event.automationId);
|
||||
emit(state.copyWith(
|
||||
automations: updatedAutomations,
|
||||
loadingAutomationIds: updatedLoadingIds,
|
||||
@ -1449,4 +1451,24 @@ Future<void> _onLoadScenes(
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
List<ScenesModel> changeItemStateOnToggelingSceen(
|
||||
List<ScenesModel> oldSceen, String automationId) {
|
||||
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