mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 22:57:21 +00:00
Refactor AC device controls and toggle widget
This commit is contained in:
@ -331,10 +331,13 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
|
||||
|
||||
try {
|
||||
final scaledValue = totalMinutes ~/ 6;
|
||||
await DevicesManagementApi().deviceControl(
|
||||
deviceId,
|
||||
Status(code: 'countdown_time', value: scaledValue),
|
||||
);
|
||||
Future.delayed(const Duration(seconds: 1), () async {
|
||||
await DevicesManagementApi().deviceControl(
|
||||
deviceId,
|
||||
Status(code: 'countdown_time', value: scaledValue),
|
||||
);
|
||||
});
|
||||
|
||||
_startCountdownTimer(emit);
|
||||
emit(currentState.copyWith(isTimerActive: timerActive));
|
||||
} catch (e) {
|
||||
@ -342,10 +345,12 @@ class AcBloc extends Bloc<AcsEvent, AcsState> {
|
||||
emit(AcsFailedState(error: e.toString()));
|
||||
}
|
||||
} else {
|
||||
await DevicesManagementApi().deviceControl(
|
||||
deviceId,
|
||||
Status(code: 'countdown_time', value: 0),
|
||||
);
|
||||
Future.delayed(const Duration(seconds: 1), () async {
|
||||
await DevicesManagementApi().deviceControl(
|
||||
deviceId,
|
||||
Status(code: 'countdown_time', value: 0),
|
||||
);
|
||||
});
|
||||
_countdownTimer?.cancel();
|
||||
scheduledHours = 0;
|
||||
scheduledMinutes = 0;
|
||||
|
Reference in New Issue
Block a user