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:
misha
2026-04-07 10:05:11 +03:00
parent b6b13b1db5
commit aac085def4
133 changed files with 2344 additions and 2456 deletions

View File

@@ -9,6 +9,7 @@ import 'package:eatvio_app/features/diets/presentation/cubit/about_diet_state.da
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
import 'package:eatvio_app/features/profile/repositories/profile_repository.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:eatvio_app/core/error_reporting/report_from.dart';
class AboutDietCubit extends Cubit<AboutDietState> {
AboutDietCubit({required this.dietsRepository, required this.profileRepository}) : super(const AboutDietState.initial());
@@ -31,7 +32,8 @@ class AboutDietCubit extends Cubit<AboutDietState> {
dietsRepository.emitCommentsStateToFeed(CommentsState(index: index, totalComments: diet.totalComments));
}
emit(AboutDietState.loaded(diet: diet, isStarted: isCurrentDietStarted, hasStartedDiet: hasStartedDiet));
} catch (e) {
} catch (e, st) {
await reportFrom(e, st, this);
log(e.toString());
emit(AboutDietState.error(message: e.toString()));
}
@@ -62,7 +64,8 @@ class AboutDietCubit extends Cubit<AboutDietState> {
}
_selectedIndexes = List.generate(diet.dailySchedule.length, (index) => 0);
emit(AboutDietState.loaded(diet: diet, isStarted: isCurrentDietStarted, hasStartedDiet: hasStartedDiet, selectedIndexes: _selectedIndexes));
} catch (e) {
} catch (e, st) {
await reportFrom(e, st, this);
log(e.toString());
emit(AboutDietState.error(message: e.toString()));
}
@@ -90,7 +93,8 @@ class AboutDietCubit extends Cubit<AboutDietState> {
EasyDebounce.debounce('like_diet', const Duration(seconds: 1), () async {
try {
await dietsRepository.likeDiet(id);
} catch (e) {
} catch (e, st) {
await reportFrom(e, st, this);
log(e.toString());
if (dietIndexInFeed != null) {
dietsRepository.emitLikesStateToFeed(LikesState(wasLikedByMe: currentDiet.wasLikedByMe, totalLikes: currentDiet.totalLikes, index: dietIndexInFeed));
@@ -114,7 +118,8 @@ class AboutDietCubit extends Cubit<AboutDietState> {
EasyDebounce.debounce('add_or_remove_diet_to_favorites', const Duration(seconds: 1), () async {
try {
await dietsRepository.addToFavorite(id);
} catch (e) {
} catch (e, st) {
await reportFrom(e, st, this);
log(e.toString());
showErrorToast('Произошла ошибка. Попробуйте ещё раз через некоторое время');
if (dietIndex != null) {
@@ -139,7 +144,8 @@ class AboutDietCubit extends Cubit<AboutDietState> {
EasyDebounce.debounce('add_or_remove_diet_to_favorites', const Duration(seconds: 1), () async {
try {
await dietsRepository.removeFromFavorite(id);
} catch (e) {
} catch (e, st) {
await reportFrom(e, st, this);
log(e.toString());
showErrorToast('Произошла ошибка. Попробуйте ещё раз через некоторое время');
if (dietIndex != null) {
@@ -159,6 +165,7 @@ class AboutDietCubit extends Cubit<AboutDietState> {
await dietsRepository.startDiet(id, stringDate);
return true;
} catch (e, st) {
await reportFrom(e, st, this);
log(e.toString(), stackTrace: st);
return false;
}
@@ -170,10 +177,12 @@ class AboutDietCubit extends Cubit<AboutDietState> {
final id = (state as DietStateLoaded).diet.id;
await dietsRepository.cancelDiet(id);
return true;
} on DioException catch (e) {
} on DioException catch (e, st) {
await reportFrom(e, st, this);
log(e.toString());
return false;
} catch (e) {
} catch (e, st) {
await reportFrom(e, st, this);
log(e.toString());
return false;
}
@@ -194,7 +203,8 @@ class AboutDietCubit extends Cubit<AboutDietState> {
Future<Diet?> getDietBySlug(String slug) async {
try {
return await dietsRepository.getDietBySlug(slug);
} catch (e) {
} catch (e, st) {
await reportFrom(e, st, this);
log(e.toString());
}
return null;

View File

@@ -4,7 +4,6 @@ import 'package:eatvio_app/features/diets/models/diet_likes_model.dart';
import 'package:eatvio_app/features/diets/services/diet_service.dart';
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
import 'package:equatable/equatable.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class DietRepository {
DietRepository({required this.dietsService});
@@ -18,76 +17,44 @@ class DietRepository {
Stream get dietCommentsState => _dietCommentsStateStreamController.stream;
Future<DietLikesModel> likeDiet(int id) async {
try {
return await dietsService.likeDiet(id: id);
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
return await dietsService.likeDiet(id: id);
}
Future<Diet> getDiet(int id) async {
try {
final diet = await dietsService.getDiet(id: id);
return diet;
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
final diet = await dietsService.getDiet(id: id);
return diet;
}
Future<Diet> getDietBySlug(String slug) async {
try {
final diet = await dietsService.getDietBySlug(slug: slug);
return diet;
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
final diet = await dietsService.getDietBySlug(slug: slug);
return diet;
}
Future<Diet> addToFavorite(int id) async {
try {
return await dietsService.addToFavorite(id: id);
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
return await dietsService.addToFavorite(id: id);
}
Future<Diet> removeFromFavorite(int id) async {
try {
return await dietsService.removeFromFavorite(id: id);
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
return await dietsService.removeFromFavorite(id: id);
}
Future<void> startDiet(int id, String date) async {
try {
return await dietsService.startDiet(id: id, body: {'date': date});
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
return await dietsService.startDiet(id: id, body: {'date': date});
}
Future<void> cancelDiet(int id) async{
try {
return await dietsService.cancelDiet(id: id);
} catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
rethrow;
}
return await dietsService.cancelDiet(id: id);
}
Future<void> deleteDiet(int id) async {
try {
return await dietsService.deleteDiet(id: id);
} catch (e) {
rethrow;
}
return dietsService.deleteDiet(id: id);
}
void emitLikesStateToFeed(LikesState state) => _dietLikeStateStreamController.add(state);