mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-08-26 07:39:40 +00:00
refactor: extract device fetching logic into a separate method for improved readability
This commit is contained in:
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user