mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
push factory reset logic and call for all devices
This commit is contained in:
@ -15,6 +15,7 @@ class CurtainBloc extends Bloc<CurtainEvent, CurtainState> {
|
||||
on<CurtainFetchBatchStatus>(_onFetchBatchStatus);
|
||||
on<CurtainControl>(_onCurtainControl);
|
||||
on<CurtainBatchControl>(_onCurtainBatchControl);
|
||||
on<CurtainFactoryReset>(_onFactoryReset);
|
||||
}
|
||||
|
||||
FutureOr<void> _onFetchDeviceStatus(
|
||||
@ -139,4 +140,22 @@ class CurtainBloc extends Bloc<CurtainEvent, CurtainState> {
|
||||
isBatch: true,
|
||||
);
|
||||
}
|
||||
|
||||
FutureOr<void> _onFactoryReset(
|
||||
CurtainFactoryReset event, Emitter<CurtainState> emit) async {
|
||||
emit(CurtainStatusLoading());
|
||||
try {
|
||||
final response = await DevicesManagementApi().factoryReset(
|
||||
event.factoryReset,
|
||||
event.deviceId,
|
||||
);
|
||||
if (!response) {
|
||||
emit(const CurtainControlError('Failed'));
|
||||
} else {
|
||||
add(CurtainFetchDeviceStatus(event.deviceId));
|
||||
}
|
||||
} catch (e) {
|
||||
emit(CurtainControlError(e.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user