mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-08-26 07:49:40 +00:00
remove_real_time
This commit is contained in:
@ -246,7 +246,9 @@ class AuthCubit extends Cubit<AuthState> {
|
||||
});
|
||||
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<AuthState> {
|
||||
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<AuthState> {
|
||||
(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<AuthState> {
|
||||
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<AuthState> {
|
||||
email: email, password: password, otpCode: otpCode);
|
||||
emit(AuthForgetPassSuccess());
|
||||
} catch (_) {
|
||||
emit(AuthForgetPassError(message: 'Something went wrong'));
|
||||
emit(AuthErrorStatusWithoutMsg());
|
||||
// emit(AuthForgetPassError(message: 'Something went wrong'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ class ACsBloc extends Bloc<AcsEvent, AcsState> {
|
||||
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()));
|
||||
|
@ -29,7 +29,7 @@ class CeilingSensorBloc extends Bloc<CeilingSensorEvent, CeilingSensorState> {
|
||||
}
|
||||
deviceStatus = CeilingSensorModel.fromJson(statusModelList);
|
||||
emit(UpdateState(ceilingSensorModel: deviceStatus));
|
||||
_listenToChanges();
|
||||
// _listenToChanges();
|
||||
} catch (e) {
|
||||
emit(FailedState(error: e.toString()));
|
||||
return;
|
||||
|
@ -40,7 +40,7 @@ class DoorSensorBloc extends Bloc<DoorSensorEvent, DoorSensorState> {
|
||||
);
|
||||
emit(UpdateState(doorSensor: deviceStatus));
|
||||
Future.delayed(const Duration(milliseconds: 500));
|
||||
_listenToChanges();
|
||||
// _listenToChanges();
|
||||
} catch (e) {
|
||||
emit(DoorSensorFailedState(errorMessage: e.toString()));
|
||||
return;
|
||||
|
@ -80,7 +80,7 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
||||
toggleDoor = deviceStatus.switch1;
|
||||
emit(UpdateState(garageSensor: deviceStatus));
|
||||
Future.delayed(const Duration(milliseconds: 500));
|
||||
_listenToChanges();
|
||||
// _listenToChanges();
|
||||
} catch (e) {
|
||||
emit(GarageDoorFailedState(errorMessage: e.toString()));
|
||||
return;
|
||||
|
@ -59,7 +59,7 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
||||
}
|
||||
deviceStatus = OneGangModel.fromJson(statusModelList);
|
||||
emit(UpdateState(oneGangModel: deviceStatus));
|
||||
_listenToChanges();
|
||||
// _listenToChanges();
|
||||
} catch (e) {
|
||||
emit(FailedState(error: e.toString()));
|
||||
return;
|
||||
|
@ -63,7 +63,7 @@ class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
||||
}
|
||||
deviceStatus = OneTouchModel.fromJson(statusModelList);
|
||||
emit(UpdateState(oneTouchModel: deviceStatus));
|
||||
_listenToChanges();
|
||||
// _listenToChanges();
|
||||
} catch (e) {
|
||||
emit(FailedState(error: e.toString()));
|
||||
return;
|
||||
|
@ -102,7 +102,7 @@ class SmartDoorBloc extends Bloc<SmartDoorEvent, SmartDoorState> {
|
||||
}
|
||||
deviceStatus = SmartDoorModel.fromJson(statusModelList);
|
||||
emit(UpdateState(smartDoorModel: deviceStatus));
|
||||
_listenToChanges();
|
||||
// _listenToChanges();
|
||||
} catch (e) {
|
||||
emit(FailedState(errorMessage: e.toString()));
|
||||
return;
|
||||
|
@ -101,7 +101,7 @@ class ThreeGangBloc extends Bloc<ThreeGangEvent, ThreeGangState> {
|
||||
}
|
||||
deviceStatus = ThreeGangModel.fromJson(statusModelList);
|
||||
emit(UpdateState(threeGangModel: deviceStatus));
|
||||
_listenToChanges();
|
||||
// _listenToChanges();
|
||||
}
|
||||
} catch (e) {
|
||||
emit(FailedState(error: e.toString()));
|
||||
|
@ -107,7 +107,7 @@ class ThreeTouchBloc extends Bloc<ThreeTouchEvent, ThreeTouchState> {
|
||||
}
|
||||
deviceStatus = ThreeTouchModel.fromJson(statusModelList);
|
||||
emit(UpdateState(threeTouchModel: deviceStatus));
|
||||
_listenToChanges();
|
||||
// _listenToChanges();
|
||||
}
|
||||
} catch (e) {
|
||||
emit(FailedState(error: e.toString()));
|
||||
|
@ -89,7 +89,7 @@ class TwoGangBloc extends Bloc<TwoGangEvent, TwoGangState> {
|
||||
}
|
||||
deviceStatus = TwoGangModel.fromJson(statusModelList);
|
||||
emit(UpdateState(twoGangModel: deviceStatus));
|
||||
_listenToChanges();
|
||||
// _listenToChanges();
|
||||
} catch (e) {
|
||||
emit(FailedState(error: e.toString()));
|
||||
return;
|
||||
|
@ -95,7 +95,7 @@ class TwoTouchBloc extends Bloc<TwoTouchEvent, TwoTouchState> {
|
||||
}
|
||||
deviceStatus = TwoTouchModel.fromJson(statusModelList);
|
||||
emit(UpdateState(twoTouchModel: deviceStatus));
|
||||
_listenToChanges();
|
||||
// _listenToChanges();
|
||||
} catch (e) {
|
||||
emit(FailedState(error: e.toString()));
|
||||
return;
|
||||
|
@ -30,7 +30,7 @@ class WallSensorBloc extends Bloc<WallSensorEvent, WallSensorState> {
|
||||
}
|
||||
deviceStatus = WallSensorModel.fromJson(statusModelList);
|
||||
emit(UpdateState(wallSensorModel: deviceStatus));
|
||||
_listenToChanges();
|
||||
// _listenToChanges();
|
||||
} catch (e) {
|
||||
emit(FailedState(error: e.toString()));
|
||||
return;
|
||||
|
@ -72,7 +72,7 @@ class WaterHeaterBloc extends Bloc<WaterHeaterEvent, WaterHeaterState> {
|
||||
statusModelList,
|
||||
);
|
||||
emit(UpdateState(whModel: deviceStatus));
|
||||
_listenToChanges();
|
||||
// _listenToChanges();
|
||||
} catch (e) {
|
||||
emit(WHFailedState(errorMessage: e.toString()));
|
||||
return;
|
||||
|
@ -25,9 +25,11 @@ class WaterLeakBloc extends Bloc<WaterLeakEvent, WaterLeakState> {
|
||||
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<WaterLeakState> emit) async {
|
||||
void _fetchStatus(
|
||||
WaterLeakInitial event, Emitter<WaterLeakState> emit) async {
|
||||
emit(WaterLeakLoadingState());
|
||||
try {
|
||||
var response = await DevicesAPI.getDeviceStatus(WLId);
|
||||
@ -41,14 +43,15 @@ class WaterLeakBloc extends Bloc<WaterLeakEvent, WaterLeakState> {
|
||||
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<WaterLeakState> emit) async {
|
||||
void _toggleLowBattery(
|
||||
ToggleLowBatteryEvent event, Emitter<WaterLeakState> emit) async {
|
||||
emit(LoadingNewSate(waterSensor: deviceStatus));
|
||||
try {
|
||||
lowBattery = event.isLowBatteryEnabled;
|
||||
@ -87,7 +90,8 @@ class WaterLeakBloc extends Bloc<WaterLeakEvent, WaterLeakState> {
|
||||
}
|
||||
}
|
||||
|
||||
void _toggleWaterLeakAlarm(ToggleWaterLeakAlarmEvent event, Emitter<WaterLeakState> emit) async {
|
||||
void _toggleWaterLeakAlarm(
|
||||
ToggleWaterLeakAlarmEvent event, Emitter<WaterLeakState> emit) async {
|
||||
emit(LoadingNewSate(waterSensor: deviceStatus));
|
||||
try {
|
||||
waterAlarm = event.isWaterLeakAlarmEnabled;
|
||||
@ -105,9 +109,11 @@ class WaterLeakBloc extends Bloc<WaterLeakEvent, WaterLeakState> {
|
||||
}
|
||||
}
|
||||
|
||||
DeviceReport recordGroups = DeviceReport(startTime: '0', endTime: '0', data: []);
|
||||
DeviceReport recordGroups =
|
||||
DeviceReport(startTime: '0', endTime: '0', data: []);
|
||||
|
||||
Future<void> fetchLogsForLastMonth(ReportLogsInitial event, Emitter<WaterLeakState> emit) async {
|
||||
Future<void> fetchLogsForLastMonth(
|
||||
ReportLogsInitial event, Emitter<WaterLeakState> 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<WaterLeakEvent, WaterLeakState> {
|
||||
|
||||
_listenToChanges() {
|
||||
try {
|
||||
DatabaseReference ref = FirebaseDatabase.instance.ref('device-status/$WLId');
|
||||
DatabaseReference ref =
|
||||
FirebaseDatabase.instance.ref('device-status/$WLId');
|
||||
Stream<DatabaseEvent> stream = ref.onValue;
|
||||
|
||||
stream.listen((DatabaseEvent event) async {
|
||||
if (_timer != null) {
|
||||
await Future.delayed(const Duration(seconds: 2));
|
||||
}
|
||||
Map<dynamic, dynamic> usersMap = event.snapshot.value as Map<dynamic, dynamic>;
|
||||
Map<dynamic, dynamic> usersMap =
|
||||
event.snapshot.value as Map<dynamic, dynamic>;
|
||||
List<StatusModel> statusList = [];
|
||||
|
||||
usersMap['status'].forEach((element) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user