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());
|
emit(AuthSignUpSuccess());
|
||||||
} catch (_) {
|
} 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());
|
emit(ResendOtpSuccess());
|
||||||
return true;
|
return true;
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
emit(AuthLoginError(message: 'Something went wrong'));
|
emit(AuthErrorStatusWithoutMsg());
|
||||||
|
|
||||||
|
// emit(AuthLoginError(message: 'Something went wrong'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,7 +303,9 @@ class AuthCubit extends Cubit<AuthState> {
|
|||||||
(Route route) => false,
|
(Route route) => false,
|
||||||
);
|
);
|
||||||
} catch (failure) {
|
} catch (failure) {
|
||||||
emit(AuthLogoutError(message: 'Something went wrong'));
|
emit(AuthErrorStatusWithoutMsg());
|
||||||
|
|
||||||
|
// emit(AuthLogoutError(message: 'Something went wrong'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -340,7 +346,9 @@ class AuthCubit extends Cubit<AuthState> {
|
|||||||
emit(AuthTokenError(message: "Something went wrong"));
|
emit(AuthTokenError(message: "Something went wrong"));
|
||||||
}
|
}
|
||||||
} catch (_) {
|
} 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);
|
email: email, password: password, otpCode: otpCode);
|
||||||
emit(AuthForgetPassSuccess());
|
emit(AuthForgetPassSuccess());
|
||||||
} catch (_) {
|
} 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});
|
AuthTokenError({required super.message, super.code});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//ForgetPassword log states
|
//ForgetPassword log states
|
||||||
class AuthForgetPassLoading extends AuthLoading {}
|
class AuthForgetPassLoading extends AuthLoading {}
|
||||||
|
|
||||||
@ -64,3 +61,6 @@ class AuthForgetPassError extends AuthError {
|
|||||||
AuthForgetPassError({required super.message, super.code});
|
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);
|
deviceStatus = AcStatusModel.fromJson(response['productUuid'], statusModelList);
|
||||||
emit(GetAcStatusState(acStatusModel: deviceStatus));
|
emit(GetAcStatusState(acStatusModel: deviceStatus));
|
||||||
Future.delayed(const Duration(milliseconds: 500));
|
Future.delayed(const Duration(milliseconds: 500));
|
||||||
_listenToChanges();
|
// _listenToChanges();
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(AcsFailedState(errorMessage: e.toString()));
|
emit(AcsFailedState(errorMessage: e.toString()));
|
||||||
|
@ -29,7 +29,7 @@ class CeilingSensorBloc extends Bloc<CeilingSensorEvent, CeilingSensorState> {
|
|||||||
}
|
}
|
||||||
deviceStatus = CeilingSensorModel.fromJson(statusModelList);
|
deviceStatus = CeilingSensorModel.fromJson(statusModelList);
|
||||||
emit(UpdateState(ceilingSensorModel: deviceStatus));
|
emit(UpdateState(ceilingSensorModel: deviceStatus));
|
||||||
_listenToChanges();
|
// _listenToChanges();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(FailedState(error: e.toString()));
|
emit(FailedState(error: e.toString()));
|
||||||
return;
|
return;
|
||||||
|
@ -40,7 +40,7 @@ class DoorSensorBloc extends Bloc<DoorSensorEvent, DoorSensorState> {
|
|||||||
);
|
);
|
||||||
emit(UpdateState(doorSensor: deviceStatus));
|
emit(UpdateState(doorSensor: deviceStatus));
|
||||||
Future.delayed(const Duration(milliseconds: 500));
|
Future.delayed(const Duration(milliseconds: 500));
|
||||||
_listenToChanges();
|
// _listenToChanges();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(DoorSensorFailedState(errorMessage: e.toString()));
|
emit(DoorSensorFailedState(errorMessage: e.toString()));
|
||||||
return;
|
return;
|
||||||
|
@ -80,7 +80,7 @@ class GarageDoorBloc extends Bloc<GarageDoorEvent, GarageDoorSensorState> {
|
|||||||
toggleDoor = deviceStatus.switch1;
|
toggleDoor = deviceStatus.switch1;
|
||||||
emit(UpdateState(garageSensor: deviceStatus));
|
emit(UpdateState(garageSensor: deviceStatus));
|
||||||
Future.delayed(const Duration(milliseconds: 500));
|
Future.delayed(const Duration(milliseconds: 500));
|
||||||
_listenToChanges();
|
// _listenToChanges();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(GarageDoorFailedState(errorMessage: e.toString()));
|
emit(GarageDoorFailedState(errorMessage: e.toString()));
|
||||||
return;
|
return;
|
||||||
|
@ -59,7 +59,7 @@ class OneGangBloc extends Bloc<OneGangEvent, OneGangState> {
|
|||||||
}
|
}
|
||||||
deviceStatus = OneGangModel.fromJson(statusModelList);
|
deviceStatus = OneGangModel.fromJson(statusModelList);
|
||||||
emit(UpdateState(oneGangModel: deviceStatus));
|
emit(UpdateState(oneGangModel: deviceStatus));
|
||||||
_listenToChanges();
|
// _listenToChanges();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(FailedState(error: e.toString()));
|
emit(FailedState(error: e.toString()));
|
||||||
return;
|
return;
|
||||||
|
@ -63,7 +63,7 @@ class OneTouchBloc extends Bloc<OneTouchEvent, OneTouchState> {
|
|||||||
}
|
}
|
||||||
deviceStatus = OneTouchModel.fromJson(statusModelList);
|
deviceStatus = OneTouchModel.fromJson(statusModelList);
|
||||||
emit(UpdateState(oneTouchModel: deviceStatus));
|
emit(UpdateState(oneTouchModel: deviceStatus));
|
||||||
_listenToChanges();
|
// _listenToChanges();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(FailedState(error: e.toString()));
|
emit(FailedState(error: e.toString()));
|
||||||
return;
|
return;
|
||||||
|
@ -102,7 +102,7 @@ class SmartDoorBloc extends Bloc<SmartDoorEvent, SmartDoorState> {
|
|||||||
}
|
}
|
||||||
deviceStatus = SmartDoorModel.fromJson(statusModelList);
|
deviceStatus = SmartDoorModel.fromJson(statusModelList);
|
||||||
emit(UpdateState(smartDoorModel: deviceStatus));
|
emit(UpdateState(smartDoorModel: deviceStatus));
|
||||||
_listenToChanges();
|
// _listenToChanges();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(FailedState(errorMessage: e.toString()));
|
emit(FailedState(errorMessage: e.toString()));
|
||||||
return;
|
return;
|
||||||
|
@ -101,7 +101,7 @@ class ThreeGangBloc extends Bloc<ThreeGangEvent, ThreeGangState> {
|
|||||||
}
|
}
|
||||||
deviceStatus = ThreeGangModel.fromJson(statusModelList);
|
deviceStatus = ThreeGangModel.fromJson(statusModelList);
|
||||||
emit(UpdateState(threeGangModel: deviceStatus));
|
emit(UpdateState(threeGangModel: deviceStatus));
|
||||||
_listenToChanges();
|
// _listenToChanges();
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(FailedState(error: e.toString()));
|
emit(FailedState(error: e.toString()));
|
||||||
|
@ -107,7 +107,7 @@ class ThreeTouchBloc extends Bloc<ThreeTouchEvent, ThreeTouchState> {
|
|||||||
}
|
}
|
||||||
deviceStatus = ThreeTouchModel.fromJson(statusModelList);
|
deviceStatus = ThreeTouchModel.fromJson(statusModelList);
|
||||||
emit(UpdateState(threeTouchModel: deviceStatus));
|
emit(UpdateState(threeTouchModel: deviceStatus));
|
||||||
_listenToChanges();
|
// _listenToChanges();
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(FailedState(error: e.toString()));
|
emit(FailedState(error: e.toString()));
|
||||||
|
@ -89,7 +89,7 @@ class TwoGangBloc extends Bloc<TwoGangEvent, TwoGangState> {
|
|||||||
}
|
}
|
||||||
deviceStatus = TwoGangModel.fromJson(statusModelList);
|
deviceStatus = TwoGangModel.fromJson(statusModelList);
|
||||||
emit(UpdateState(twoGangModel: deviceStatus));
|
emit(UpdateState(twoGangModel: deviceStatus));
|
||||||
_listenToChanges();
|
// _listenToChanges();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(FailedState(error: e.toString()));
|
emit(FailedState(error: e.toString()));
|
||||||
return;
|
return;
|
||||||
|
@ -95,7 +95,7 @@ class TwoTouchBloc extends Bloc<TwoTouchEvent, TwoTouchState> {
|
|||||||
}
|
}
|
||||||
deviceStatus = TwoTouchModel.fromJson(statusModelList);
|
deviceStatus = TwoTouchModel.fromJson(statusModelList);
|
||||||
emit(UpdateState(twoTouchModel: deviceStatus));
|
emit(UpdateState(twoTouchModel: deviceStatus));
|
||||||
_listenToChanges();
|
// _listenToChanges();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(FailedState(error: e.toString()));
|
emit(FailedState(error: e.toString()));
|
||||||
return;
|
return;
|
||||||
|
@ -30,7 +30,7 @@ class WallSensorBloc extends Bloc<WallSensorEvent, WallSensorState> {
|
|||||||
}
|
}
|
||||||
deviceStatus = WallSensorModel.fromJson(statusModelList);
|
deviceStatus = WallSensorModel.fromJson(statusModelList);
|
||||||
emit(UpdateState(wallSensorModel: deviceStatus));
|
emit(UpdateState(wallSensorModel: deviceStatus));
|
||||||
_listenToChanges();
|
// _listenToChanges();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(FailedState(error: e.toString()));
|
emit(FailedState(error: e.toString()));
|
||||||
return;
|
return;
|
||||||
|
@ -72,7 +72,7 @@ class WaterHeaterBloc extends Bloc<WaterHeaterEvent, WaterHeaterState> {
|
|||||||
statusModelList,
|
statusModelList,
|
||||||
);
|
);
|
||||||
emit(UpdateState(whModel: deviceStatus));
|
emit(UpdateState(whModel: deviceStatus));
|
||||||
_listenToChanges();
|
// _listenToChanges();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(WHFailedState(errorMessage: e.toString()));
|
emit(WHFailedState(errorMessage: e.toString()));
|
||||||
return;
|
return;
|
||||||
|
@ -25,9 +25,11 @@ class WaterLeakBloc extends Bloc<WaterLeakEvent, WaterLeakState> {
|
|||||||
bool lowBattery = false;
|
bool lowBattery = false;
|
||||||
bool closingReminder = false;
|
bool closingReminder = false;
|
||||||
bool waterAlarm = 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());
|
emit(WaterLeakLoadingState());
|
||||||
try {
|
try {
|
||||||
var response = await DevicesAPI.getDeviceStatus(WLId);
|
var response = await DevicesAPI.getDeviceStatus(WLId);
|
||||||
@ -41,14 +43,15 @@ class WaterLeakBloc extends Bloc<WaterLeakEvent, WaterLeakState> {
|
|||||||
emit(UpdateState(waterSensor: deviceStatus));
|
emit(UpdateState(waterSensor: deviceStatus));
|
||||||
|
|
||||||
Future.delayed(const Duration(milliseconds: 500));
|
Future.delayed(const Duration(milliseconds: 500));
|
||||||
_listenToChanges();
|
// _listenToChanges();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
emit(WaterLeakFailedState(errorMessage: e.toString()));
|
emit(WaterLeakFailedState(errorMessage: e.toString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _toggleLowBattery(ToggleLowBatteryEvent event, Emitter<WaterLeakState> emit) async {
|
void _toggleLowBattery(
|
||||||
|
ToggleLowBatteryEvent event, Emitter<WaterLeakState> emit) async {
|
||||||
emit(LoadingNewSate(waterSensor: deviceStatus));
|
emit(LoadingNewSate(waterSensor: deviceStatus));
|
||||||
try {
|
try {
|
||||||
lowBattery = event.isLowBatteryEnabled;
|
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));
|
emit(LoadingNewSate(waterSensor: deviceStatus));
|
||||||
try {
|
try {
|
||||||
waterAlarm = event.isWaterLeakAlarmEnabled;
|
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 now = DateTime.now();
|
||||||
DateTime lastMonth = DateTime(now.year, now.month - 1, now.day);
|
DateTime lastMonth = DateTime(now.year, now.month - 1, now.day);
|
||||||
int startTime = lastMonth.millisecondsSinceEpoch;
|
int startTime = lastMonth.millisecondsSinceEpoch;
|
||||||
@ -131,14 +137,16 @@ class WaterLeakBloc extends Bloc<WaterLeakEvent, WaterLeakState> {
|
|||||||
|
|
||||||
_listenToChanges() {
|
_listenToChanges() {
|
||||||
try {
|
try {
|
||||||
DatabaseReference ref = FirebaseDatabase.instance.ref('device-status/$WLId');
|
DatabaseReference ref =
|
||||||
|
FirebaseDatabase.instance.ref('device-status/$WLId');
|
||||||
Stream<DatabaseEvent> stream = ref.onValue;
|
Stream<DatabaseEvent> stream = ref.onValue;
|
||||||
|
|
||||||
stream.listen((DatabaseEvent event) async {
|
stream.listen((DatabaseEvent event) async {
|
||||||
if (_timer != null) {
|
if (_timer != null) {
|
||||||
await Future.delayed(const Duration(seconds: 2));
|
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 = [];
|
List<StatusModel> statusList = [];
|
||||||
|
|
||||||
usersMap['status'].forEach((element) {
|
usersMap['status'].forEach((element) {
|
||||||
|
@ -40,7 +40,10 @@ class AuthenticationAPI {
|
|||||||
path: ApiEndpoints.sendOtp,
|
path: ApiEndpoints.sendOtp,
|
||||||
body: body,
|
body: body,
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) => json['data']);
|
expectedResponseModel: (json) {
|
||||||
|
print(json['data']);
|
||||||
|
return json['data'];
|
||||||
|
});
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user