diff --git a/lib/features/auth/bloc/auth_cubit.dart b/lib/features/auth/bloc/auth_cubit.dart index 6e4eaf6..1eff828 100644 --- a/lib/features/auth/bloc/auth_cubit.dart +++ b/lib/features/auth/bloc/auth_cubit.dart @@ -246,7 +246,9 @@ class AuthCubit extends Cubit { }); emit(AuthSignUpSuccess()); } catch (_) { - emit(AuthLoginError(message: 'Something went wrong')); + emit(AuthErrorStatusWithoutMsg()); + + // emit(AuthLoginError(message: 'Something went wrong')); } } @@ -260,7 +262,9 @@ class AuthCubit extends Cubit { emit(ResendOtpSuccess()); return true; } catch (_) { - emit(AuthLoginError(message: 'Something went wrong')); + emit(AuthErrorStatusWithoutMsg()); + + // emit(AuthLoginError(message: 'Something went wrong')); return false; } } @@ -299,7 +303,9 @@ class AuthCubit extends Cubit { (Route route) => false, ); } catch (failure) { - emit(AuthLogoutError(message: 'Something went wrong')); + emit(AuthErrorStatusWithoutMsg()); + + // emit(AuthLogoutError(message: 'Something went wrong')); return; } } @@ -340,7 +346,9 @@ class AuthCubit extends Cubit { emit(AuthTokenError(message: "Something went wrong")); } } catch (_) { - emit(AuthTokenError(message: "Something went wrong")); + emit(AuthErrorStatusWithoutMsg()); + + // emit(AuthTokenError(message: "Something went wrong")); } } @@ -352,7 +360,8 @@ class AuthCubit extends Cubit { email: email, password: password, otpCode: otpCode); emit(AuthForgetPassSuccess()); } catch (_) { - emit(AuthForgetPassError(message: 'Something went wrong')); + emit(AuthErrorStatusWithoutMsg()); + // emit(AuthForgetPassError(message: 'Something went wrong')); } } } diff --git a/lib/features/auth/bloc/auth_state.dart b/lib/features/auth/bloc/auth_state.dart index 9dbcc2b..1692d4b 100644 --- a/lib/features/auth/bloc/auth_state.dart +++ b/lib/features/auth/bloc/auth_state.dart @@ -52,9 +52,6 @@ class AuthTokenError extends AuthError { AuthTokenError({required super.message, super.code}); } - - - //ForgetPassword log states class AuthForgetPassLoading extends AuthLoading {} @@ -64,3 +61,6 @@ class AuthForgetPassError extends AuthError { AuthForgetPassError({required super.message, super.code}); } +class AuthErrorStatusWithoutMsg extends AuthState { + AuthErrorStatusWithoutMsg(); +} diff --git a/lib/features/devices/bloc/acs_bloc/acs_bloc.dart b/lib/features/devices/bloc/acs_bloc/acs_bloc.dart index c8a8350..8750369 100644 --- a/lib/features/devices/bloc/acs_bloc/acs_bloc.dart +++ b/lib/features/devices/bloc/acs_bloc/acs_bloc.dart @@ -64,7 +64,7 @@ class ACsBloc extends Bloc { deviceStatus = AcStatusModel.fromJson(response['productUuid'], statusModelList); emit(GetAcStatusState(acStatusModel: deviceStatus)); Future.delayed(const Duration(milliseconds: 500)); - _listenToChanges(); + // _listenToChanges(); } } catch (e) { emit(AcsFailedState(errorMessage: e.toString())); diff --git a/lib/features/devices/bloc/ceiling_bloc/ceiling_sensor_bloc.dart b/lib/features/devices/bloc/ceiling_bloc/ceiling_sensor_bloc.dart index 536df9b..c3f2c79 100644 --- a/lib/features/devices/bloc/ceiling_bloc/ceiling_sensor_bloc.dart +++ b/lib/features/devices/bloc/ceiling_bloc/ceiling_sensor_bloc.dart @@ -29,7 +29,7 @@ class CeilingSensorBloc extends Bloc { } deviceStatus = CeilingSensorModel.fromJson(statusModelList); emit(UpdateState(ceilingSensorModel: deviceStatus)); - _listenToChanges(); + // _listenToChanges(); } catch (e) { emit(FailedState(error: e.toString())); return; diff --git a/lib/features/devices/bloc/door_sensor_bloc/door_sensor_bloc.dart b/lib/features/devices/bloc/door_sensor_bloc/door_sensor_bloc.dart index d4e31b5..15c7d76 100644 --- a/lib/features/devices/bloc/door_sensor_bloc/door_sensor_bloc.dart +++ b/lib/features/devices/bloc/door_sensor_bloc/door_sensor_bloc.dart @@ -40,7 +40,7 @@ class DoorSensorBloc extends Bloc { ); emit(UpdateState(doorSensor: deviceStatus)); Future.delayed(const Duration(milliseconds: 500)); - _listenToChanges(); + // _listenToChanges(); } catch (e) { emit(DoorSensorFailedState(errorMessage: e.toString())); return; diff --git a/lib/features/devices/bloc/garage_door_bloc/garage_door_bloc.dart b/lib/features/devices/bloc/garage_door_bloc/garage_door_bloc.dart index c2063d4..2c77400 100644 --- a/lib/features/devices/bloc/garage_door_bloc/garage_door_bloc.dart +++ b/lib/features/devices/bloc/garage_door_bloc/garage_door_bloc.dart @@ -80,7 +80,7 @@ class GarageDoorBloc extends Bloc { toggleDoor = deviceStatus.switch1; emit(UpdateState(garageSensor: deviceStatus)); Future.delayed(const Duration(milliseconds: 500)); - _listenToChanges(); + // _listenToChanges(); } catch (e) { emit(GarageDoorFailedState(errorMessage: e.toString())); return; diff --git a/lib/features/devices/bloc/one_gang_bloc/one_gang_bloc.dart b/lib/features/devices/bloc/one_gang_bloc/one_gang_bloc.dart index 6a90042..9e7161d 100644 --- a/lib/features/devices/bloc/one_gang_bloc/one_gang_bloc.dart +++ b/lib/features/devices/bloc/one_gang_bloc/one_gang_bloc.dart @@ -59,7 +59,7 @@ class OneGangBloc extends Bloc { } deviceStatus = OneGangModel.fromJson(statusModelList); emit(UpdateState(oneGangModel: deviceStatus)); - _listenToChanges(); + // _listenToChanges(); } catch (e) { emit(FailedState(error: e.toString())); return; diff --git a/lib/features/devices/bloc/one_touch_bloc/one_touch_bloc.dart b/lib/features/devices/bloc/one_touch_bloc/one_touch_bloc.dart index 0fd3f34..37e016f 100644 --- a/lib/features/devices/bloc/one_touch_bloc/one_touch_bloc.dart +++ b/lib/features/devices/bloc/one_touch_bloc/one_touch_bloc.dart @@ -63,7 +63,7 @@ class OneTouchBloc extends Bloc { } deviceStatus = OneTouchModel.fromJson(statusModelList); emit(UpdateState(oneTouchModel: deviceStatus)); - _listenToChanges(); + // _listenToChanges(); } catch (e) { emit(FailedState(error: e.toString())); return; diff --git a/lib/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart b/lib/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart index 236c623..7f1a606 100644 --- a/lib/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart +++ b/lib/features/devices/bloc/smart_door_bloc/smart_door_bloc.dart @@ -102,7 +102,7 @@ class SmartDoorBloc extends Bloc { } deviceStatus = SmartDoorModel.fromJson(statusModelList); emit(UpdateState(smartDoorModel: deviceStatus)); - _listenToChanges(); + // _listenToChanges(); } catch (e) { emit(FailedState(errorMessage: e.toString())); return; diff --git a/lib/features/devices/bloc/three_gang_bloc/three_gang_bloc.dart b/lib/features/devices/bloc/three_gang_bloc/three_gang_bloc.dart index 78b9dd1..04f434c 100644 --- a/lib/features/devices/bloc/three_gang_bloc/three_gang_bloc.dart +++ b/lib/features/devices/bloc/three_gang_bloc/three_gang_bloc.dart @@ -101,7 +101,7 @@ class ThreeGangBloc extends Bloc { } deviceStatus = ThreeGangModel.fromJson(statusModelList); emit(UpdateState(threeGangModel: deviceStatus)); - _listenToChanges(); + // _listenToChanges(); } } catch (e) { emit(FailedState(error: e.toString())); diff --git a/lib/features/devices/bloc/three_touch_bloc/three_touch_bloc.dart b/lib/features/devices/bloc/three_touch_bloc/three_touch_bloc.dart index 0ac4edd..beec442 100644 --- a/lib/features/devices/bloc/three_touch_bloc/three_touch_bloc.dart +++ b/lib/features/devices/bloc/three_touch_bloc/three_touch_bloc.dart @@ -107,7 +107,7 @@ class ThreeTouchBloc extends Bloc { } deviceStatus = ThreeTouchModel.fromJson(statusModelList); emit(UpdateState(threeTouchModel: deviceStatus)); - _listenToChanges(); + // _listenToChanges(); } } catch (e) { emit(FailedState(error: e.toString())); diff --git a/lib/features/devices/bloc/two_gang_bloc/two_gang_bloc.dart b/lib/features/devices/bloc/two_gang_bloc/two_gang_bloc.dart index bc14479..7906348 100644 --- a/lib/features/devices/bloc/two_gang_bloc/two_gang_bloc.dart +++ b/lib/features/devices/bloc/two_gang_bloc/two_gang_bloc.dart @@ -89,7 +89,7 @@ class TwoGangBloc extends Bloc { } deviceStatus = TwoGangModel.fromJson(statusModelList); emit(UpdateState(twoGangModel: deviceStatus)); - _listenToChanges(); + // _listenToChanges(); } catch (e) { emit(FailedState(error: e.toString())); return; diff --git a/lib/features/devices/bloc/two_touch_bloc/two_touch_bloc.dart b/lib/features/devices/bloc/two_touch_bloc/two_touch_bloc.dart index b83c034..7f66724 100644 --- a/lib/features/devices/bloc/two_touch_bloc/two_touch_bloc.dart +++ b/lib/features/devices/bloc/two_touch_bloc/two_touch_bloc.dart @@ -95,7 +95,7 @@ class TwoTouchBloc extends Bloc { } deviceStatus = TwoTouchModel.fromJson(statusModelList); emit(UpdateState(twoTouchModel: deviceStatus)); - _listenToChanges(); + // _listenToChanges(); } catch (e) { emit(FailedState(error: e.toString())); return; diff --git a/lib/features/devices/bloc/wall_sensor_bloc/wall_sensor_bloc.dart b/lib/features/devices/bloc/wall_sensor_bloc/wall_sensor_bloc.dart index 7c01795..1b979a6 100644 --- a/lib/features/devices/bloc/wall_sensor_bloc/wall_sensor_bloc.dart +++ b/lib/features/devices/bloc/wall_sensor_bloc/wall_sensor_bloc.dart @@ -30,7 +30,7 @@ class WallSensorBloc extends Bloc { } deviceStatus = WallSensorModel.fromJson(statusModelList); emit(UpdateState(wallSensorModel: deviceStatus)); - _listenToChanges(); + // _listenToChanges(); } catch (e) { emit(FailedState(error: e.toString())); return; diff --git a/lib/features/devices/bloc/water_heater_bloc/water_heater_bloc.dart b/lib/features/devices/bloc/water_heater_bloc/water_heater_bloc.dart index 0df2228..40f2bc7 100644 --- a/lib/features/devices/bloc/water_heater_bloc/water_heater_bloc.dart +++ b/lib/features/devices/bloc/water_heater_bloc/water_heater_bloc.dart @@ -72,7 +72,7 @@ class WaterHeaterBloc extends Bloc { statusModelList, ); emit(UpdateState(whModel: deviceStatus)); - _listenToChanges(); + // _listenToChanges(); } catch (e) { emit(WHFailedState(errorMessage: e.toString())); return; diff --git a/lib/features/devices/bloc/water_leak_bloc/water_leak_bloc.dart b/lib/features/devices/bloc/water_leak_bloc/water_leak_bloc.dart index 9e50f69..300c4f4 100644 --- a/lib/features/devices/bloc/water_leak_bloc/water_leak_bloc.dart +++ b/lib/features/devices/bloc/water_leak_bloc/water_leak_bloc.dart @@ -25,9 +25,11 @@ class WaterLeakBloc extends Bloc { bool lowBattery = false; bool closingReminder = false; bool waterAlarm = false; - WaterLeakModel deviceStatus = WaterLeakModel(waterContactState: 'normal', batteryPercentage: 0); + WaterLeakModel deviceStatus = + WaterLeakModel(waterContactState: 'normal', batteryPercentage: 0); - void _fetchStatus(WaterLeakInitial event, Emitter emit) async { + void _fetchStatus( + WaterLeakInitial event, Emitter emit) async { emit(WaterLeakLoadingState()); try { var response = await DevicesAPI.getDeviceStatus(WLId); @@ -41,14 +43,15 @@ class WaterLeakBloc extends Bloc { emit(UpdateState(waterSensor: deviceStatus)); Future.delayed(const Duration(milliseconds: 500)); - _listenToChanges(); + // _listenToChanges(); } catch (e) { emit(WaterLeakFailedState(errorMessage: e.toString())); return; } } - void _toggleLowBattery(ToggleLowBatteryEvent event, Emitter emit) async { + void _toggleLowBattery( + ToggleLowBatteryEvent event, Emitter emit) async { emit(LoadingNewSate(waterSensor: deviceStatus)); try { lowBattery = event.isLowBatteryEnabled; @@ -87,7 +90,8 @@ class WaterLeakBloc extends Bloc { } } - void _toggleWaterLeakAlarm(ToggleWaterLeakAlarmEvent event, Emitter emit) async { + void _toggleWaterLeakAlarm( + ToggleWaterLeakAlarmEvent event, Emitter emit) async { emit(LoadingNewSate(waterSensor: deviceStatus)); try { waterAlarm = event.isWaterLeakAlarmEnabled; @@ -105,9 +109,11 @@ class WaterLeakBloc extends Bloc { } } - DeviceReport recordGroups = DeviceReport(startTime: '0', endTime: '0', data: []); + DeviceReport recordGroups = + DeviceReport(startTime: '0', endTime: '0', data: []); - Future fetchLogsForLastMonth(ReportLogsInitial event, Emitter emit) async { + Future fetchLogsForLastMonth( + ReportLogsInitial event, Emitter emit) async { DateTime now = DateTime.now(); DateTime lastMonth = DateTime(now.year, now.month - 1, now.day); int startTime = lastMonth.millisecondsSinceEpoch; @@ -131,14 +137,16 @@ class WaterLeakBloc extends Bloc { _listenToChanges() { try { - DatabaseReference ref = FirebaseDatabase.instance.ref('device-status/$WLId'); + DatabaseReference ref = + FirebaseDatabase.instance.ref('device-status/$WLId'); Stream stream = ref.onValue; stream.listen((DatabaseEvent event) async { if (_timer != null) { await Future.delayed(const Duration(seconds: 2)); } - Map usersMap = event.snapshot.value as Map; + Map usersMap = + event.snapshot.value as Map; List statusList = []; usersMap['status'].forEach((element) { diff --git a/lib/services/api/authentication_api.dart b/lib/services/api/authentication_api.dart index 91bd5f1..c9755d4 100644 --- a/lib/services/api/authentication_api.dart +++ b/lib/services/api/authentication_api.dart @@ -40,7 +40,10 @@ class AuthenticationAPI { path: ApiEndpoints.sendOtp, body: body, showServerMessage: false, - expectedResponseModel: (json) => json['data']); + expectedResponseModel: (json) { + print(json['data']); + return json['data']; + }); return response; }