forked from eatvio/eatvio_app
feat(feed): fixed comments state updating in feed, feat(consultantRegistration): fixed registration flow for users with unverified phone, feat(tests): fixed tests coverage
This commit is contained in:
@@ -26,6 +26,17 @@ class FeedCubit extends Cubit<FeedState> {
|
||||
}
|
||||
}
|
||||
|
||||
void incrementCommentsState(int id) {
|
||||
final List<FeedBlogPostModel> feedBlogPostList = [...(state as FeedStateLoaded).feedBlogPostList];
|
||||
final int index = feedBlogPostList.indexWhere((e) => e.id == id);
|
||||
if (index == -1) return;
|
||||
final current = feedBlogPostList[index];
|
||||
feedBlogPostList[index] = current.copyWith(totalComments: current.totalComments + 1);
|
||||
if (!isClosed) {
|
||||
emit(FeedState.loaded(feedBlogPostList: feedBlogPostList, isLoading: isLoading));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> loadFeedBlogPostList({String? query}) async {
|
||||
try {
|
||||
_query = query;
|
||||
|
||||
@@ -33,7 +33,7 @@ import '../widgets/recipes.dart';
|
||||
|
||||
class FeedScreen extends StatelessWidget {
|
||||
const FeedScreen({super.key, this.initialTabIndex = 0});
|
||||
final int initialTabIndex;
|
||||
final int? initialTabIndex;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MultiBlocProvider(
|
||||
@@ -51,7 +51,7 @@ class FeedScreen extends StatelessWidget {
|
||||
|
||||
class FeedScreenContent extends StatefulWidget {
|
||||
const FeedScreenContent({super.key, required this.initialTabIndex});
|
||||
final int initialTabIndex;
|
||||
final int? initialTabIndex;
|
||||
@override
|
||||
State<FeedScreenContent> createState() => _FeedScreenContentState();
|
||||
}
|
||||
@@ -72,7 +72,7 @@ class _FeedScreenContentState extends State<FeedScreenContent> {
|
||||
final consultantsScrollController = ScrollController();
|
||||
@override
|
||||
void initState() {
|
||||
_selectedChipIndex = widget.initialTabIndex;
|
||||
_selectedChipIndex = widget.initialTabIndex ?? 0;
|
||||
chipsLabelList = hidePlans ? ['Все', 'Консультанты', 'Рецепты', 'Диеты'] : ['Все', 'Планы питания', 'Консультанты', 'Рецепты', 'Диеты'];
|
||||
consultantsScrollController.addListener(_onScrollConsultants);
|
||||
_checkRegistrationDate(context);
|
||||
@@ -92,8 +92,11 @@ class _FeedScreenContentState extends State<FeedScreenContent> {
|
||||
@override
|
||||
void didUpdateWidget(FeedScreenContent oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
final initialTabIndex = widget.initialTabIndex;
|
||||
setState(() {
|
||||
_selectedChipIndex = widget.initialTabIndex;
|
||||
if (initialTabIndex != null) {
|
||||
_selectedChipIndex = initialTabIndex;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user