refactor: extract device fetching logic into a separate method for improved readability

This commit is contained in:
Faris Armoush
2025-04-16 16:08:57 +03:00
parent e4768c95aa
commit f2412aa867
2 changed files with 10 additions and 5 deletions

View File

@ -15,11 +15,7 @@ class TabBarBloc extends Bloc<TabBarEvent, TabBarState> {
TabBarTabChangedEvent event,
Emitter<TabBarState> emit,
) {
if (event.roomId == "-1") {
deviceManagerBloc.add(FetchAllDevices());
} else {
deviceManagerBloc.add(FetchDevicesByRoomId(event.roomId, event.unit));
}
_getDevices(event);
emit(
TabBarTabSelectedState(
@ -28,4 +24,12 @@ class TabBarBloc extends Bloc<TabBarEvent, TabBarState> {
),
);
}
void _getDevices(TabBarTabChangedEvent event) {
if (event.roomId == "-1") {
deviceManagerBloc.add(FetchAllDevices());
} else {
deviceManagerBloc.add(FetchDevicesByRoomId(event.roomId, event.unit));
}
}
}

View File

@ -58,6 +58,7 @@ class SceneDevicesBody extends StatelessWidget {
ModalRoute.of(context)?.settings.arguments as SceneSettingsRouteArguments?;
final deviceStatusChangesScene = CreateSceneEnum.deviceStatusChanges.name;
final sceneType = routeArguments?.sceneType;
return sceneType == deviceStatusChangesScene;
}