forked from eatvio/eatvio_app
feat(app): refactoring of sentry using, feat(become_consultant): fixed possible infinite loading, feat(push_notifications): fixed push navigation from paid plan push
This commit is contained in:
@@ -9,9 +9,11 @@ import 'package:eatvio_app/core/prefs.dart';
|
||||
import 'package:eatvio_app/core/token_storage.dart';
|
||||
import 'package:eatvio_app/features/registration/models/user_registration_model.dart';
|
||||
import 'package:eatvio_app/features/registration/presentation/bloc/registration_cubit/registration_state.dart';
|
||||
import 'package:eatvio_app/features/registration/registration_error_message.dart';
|
||||
import 'package:eatvio_app/features/registration/repositories/registration_repository.dart';
|
||||
import 'package:eatvio_app/features/registration/services/registration_analytics_service.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:eatvio_app/core/error_reporting/report_from.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
class RegistrationCubit extends Cubit<RegistrationState> with RegistrationDateCacheMixin {
|
||||
@@ -65,9 +67,11 @@ class RegistrationCubit extends Cubit<RegistrationState> with RegistrationDateCa
|
||||
cacheRegistrationDate(DateTime.now());
|
||||
AppRouter.navigatorKey.currentContext?.replaceNamed('verifyEmailScreen');
|
||||
} catch (e, st) {
|
||||
log(e.toString(), stackTrace: st);
|
||||
RegistrationAnalyticsService.reportRegistrationError(e.toString());
|
||||
emit(RegistrationState(sheet: state.sheet, error: e.toString()));
|
||||
await reportFrom(e, st, this);
|
||||
final message = registrationErrorMessage(e);
|
||||
log(message, stackTrace: st);
|
||||
RegistrationAnalyticsService.reportRegistrationError(message);
|
||||
emit(RegistrationState(sheet: state.sheet, error: message));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,8 +80,9 @@ class RegistrationCubit extends Cubit<RegistrationState> with RegistrationDateCa
|
||||
final location = (await registrationRepository.getLocationsListByQuery(query));
|
||||
emit(RegistrationState(sheet: state.sheet.copyWith(responseBody: location.responseBody)));
|
||||
return location.locations;
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
} catch (e, st) {
|
||||
await reportFrom(e, st, this);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,8 +91,9 @@ class RegistrationCubit extends Cubit<RegistrationState> with RegistrationDateCa
|
||||
final location = (await registrationRepository.getLocationsListByCoordinates(latitude, longitude));
|
||||
emit(RegistrationState(sheet: state.sheet.copyWith(responseBody: location.responseBody)));
|
||||
return location.locations;
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
} catch (e, st) {
|
||||
await reportFrom(e, st, this);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:eatvio_app/features/profile/repositories/profile_repository.dart
|
||||
import 'package:eatvio_app/features/registration/presentation/bloc/verify_email_cubit/verify_email_state.dart';
|
||||
import 'package:eatvio_app/features/registration/services/registration_analytics_service.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:eatvio_app/core/error_reporting/report_from.dart';
|
||||
|
||||
class VerifyEmailCubit extends Cubit<VerifyEmailState> {
|
||||
final ProfileRepository profileRepository;
|
||||
@@ -16,7 +17,8 @@ class VerifyEmailCubit extends Cubit<VerifyEmailState> {
|
||||
final profile = await profileRepository.getMyProfile();
|
||||
await profileRepository.sendEmailCode();
|
||||
emit(VerifyEmailState.loaded(email: profile.email));
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
await reportFrom(e, st, this);
|
||||
emit(const VerifyEmailState.error(errorMessage: 'Ошибка отправки кода.\nПовторите попытку позже'));
|
||||
}
|
||||
}
|
||||
@@ -24,18 +26,15 @@ class VerifyEmailCubit extends Cubit<VerifyEmailState> {
|
||||
Future<void> tryVerify(String code) async {
|
||||
try {
|
||||
emit(const VerifyEmailState.verifyLoading());
|
||||
final result = await profileRepository.tryVerifyEmailByCode(code);
|
||||
if (result == true) {
|
||||
emit(const VerifyEmailState.verifySuccess());
|
||||
try {
|
||||
RegistrationAnalyticsService.reportEmailVerification();
|
||||
} catch (e) {
|
||||
// Игнорируем ошибки аналитики, верификация уже успешна
|
||||
}
|
||||
} else {
|
||||
emit(const VerifyEmailState.verifyError());
|
||||
await profileRepository.tryVerifyEmailByCode(code);
|
||||
emit(const VerifyEmailState.verifySuccess());
|
||||
try {
|
||||
RegistrationAnalyticsService.reportEmailVerification();
|
||||
} catch (e, st) {
|
||||
await reportFrom(e, st, this);
|
||||
}
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
await reportFrom(e, st, this);
|
||||
emit(const VerifyEmailState.verifyError());
|
||||
}
|
||||
}
|
||||
@@ -47,7 +46,8 @@ class VerifyEmailCubit extends Cubit<VerifyEmailState> {
|
||||
emit(const VerifyEmailState.changeEmailSuccess());
|
||||
// Обновляем email в состоянии после успешной смены
|
||||
emit(VerifyEmailState.loaded(email: newEmail));
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
await reportFrom(e, st, this);
|
||||
emit(const VerifyEmailState.changeEmailError());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user