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,
|
TabBarTabChangedEvent event,
|
||||||
Emitter<TabBarState> emit,
|
Emitter<TabBarState> emit,
|
||||||
) {
|
) {
|
||||||
if (event.roomId == "-1") {
|
_getDevices(event);
|
||||||
deviceManagerBloc.add(FetchAllDevices());
|
|
||||||
} else {
|
|
||||||
deviceManagerBloc.add(FetchDevicesByRoomId(event.roomId, event.unit));
|
|
||||||
}
|
|
||||||
|
|
||||||
emit(
|
emit(
|
||||||
TabBarTabSelectedState(
|
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?;
|
ModalRoute.of(context)?.settings.arguments as SceneSettingsRouteArguments?;
|
||||||
final deviceStatusChangesScene = CreateSceneEnum.deviceStatusChanges.name;
|
final deviceStatusChangesScene = CreateSceneEnum.deviceStatusChanges.name;
|
||||||
final sceneType = routeArguments?.sceneType;
|
final sceneType = routeArguments?.sceneType;
|
||||||
|
|
||||||
return sceneType == deviceStatusChangesScene;
|
return sceneType == deviceStatusChangesScene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user