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:
@@ -8,6 +8,7 @@ import 'package:eatvio_app/features/plans/models/chosen_plan_model.dart';
|
||||
import 'package:eatvio_app/features/plans/presentation/cubit/about_plan_state.dart';
|
||||
import 'package:eatvio_app/features/plans/repositories/plan_repository.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:eatvio_app/core/error_reporting/report_from.dart';
|
||||
|
||||
class AboutPlanCubit extends Cubit<AboutPlanState> {
|
||||
final PlanRepository planRepository;
|
||||
@@ -21,6 +22,7 @@ class AboutPlanCubit extends Cubit<AboutPlanState> {
|
||||
}
|
||||
emit(state.copyWith(planModel: plan, error: null));
|
||||
} catch (e, stackTrace) {
|
||||
await reportFrom(e, stackTrace, this);
|
||||
log(e.toString(), stackTrace: stackTrace);
|
||||
emit(state.copyWith(error: e.toString(), isLoading: false));
|
||||
}
|
||||
@@ -32,6 +34,7 @@ class AboutPlanCubit extends Cubit<AboutPlanState> {
|
||||
final plan = await planRepository.getPlan(slug);
|
||||
emit(state.copyWith(planModel: plan, error: null, isLoading: false));
|
||||
} catch (e, stackTrace) {
|
||||
await reportFrom(e, stackTrace, this);
|
||||
log(e.toString(), stackTrace: stackTrace);
|
||||
emit(state.copyWith(error: e.toString(), isLoading: false));
|
||||
}
|
||||
@@ -59,7 +62,8 @@ class AboutPlanCubit extends Cubit<AboutPlanState> {
|
||||
EasyDebounce.debounce('like_plan_$slug', const Duration(seconds: 1), () async {
|
||||
try {
|
||||
await planRepository.likePlan(slug);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
await reportFrom(e, st, this);
|
||||
log(e.toString());
|
||||
if (index != null) {
|
||||
planRepository.emitLikesStateToFeed(LikesState(wasLikedByMe: currentPlan.wasLikedByMe, totalLikes: currentPlan.totalLikes, index: index));
|
||||
@@ -80,7 +84,8 @@ class AboutPlanCubit extends Cubit<AboutPlanState> {
|
||||
EasyDebounce.debounce('add_or_remove_plan_to_favorites', const Duration(seconds: 1), () async {
|
||||
try {
|
||||
await planRepository.addToFavorite(slug);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
await reportFrom(e, st, this);
|
||||
log(e.toString());
|
||||
showErrorToast('Произошла ошибка. Попробуйте ещё раз через некоторое время');
|
||||
if (index != null) {
|
||||
@@ -102,7 +107,8 @@ class AboutPlanCubit extends Cubit<AboutPlanState> {
|
||||
EasyDebounce.debounce('add_or_remove_plan_to_favorites', const Duration(seconds: 1), () async {
|
||||
try {
|
||||
await planRepository.removeFromFavorite(slug);
|
||||
} catch (e) {
|
||||
} catch (e, st) {
|
||||
await reportFrom(e, st, this);
|
||||
log(e.toString());
|
||||
showErrorToast('Произошла ошибка. Попробуйте ещё раз через некоторое время');
|
||||
if (index != null) {
|
||||
@@ -123,11 +129,13 @@ class AboutPlanCubit extends Cubit<AboutPlanState> {
|
||||
return (await planRepository.chosePlan(slug, body), null);
|
||||
}
|
||||
} on DioException catch (e, st) {
|
||||
await reportFrom(e, st, this);
|
||||
if (e.response?.statusCode == 400) {
|
||||
return (null, 'hasPlan');
|
||||
}
|
||||
log(e.toString(), stackTrace: st);
|
||||
} catch (e, st) {
|
||||
await reportFrom(e, st, this);
|
||||
log(e.toString(), stackTrace: st);
|
||||
}
|
||||
return (null, '');
|
||||
|
||||
Reference in New Issue
Block a user