From 15aa1ea69aaee0139ea32c8f93e28f8cb22b71c1 Mon Sep 17 00:00:00 2001 From: James Elgar Date: Mon, 11 Nov 2024 21:15:33 +0000 Subject: [PATCH] Tweaks --- lib/main.dart | 2 +- lib/models/action.dart | 2 +- lib/models/campaign.dart | 2 +- lib/models/learning.dart | 2 +- lib/ui/components/user_progress/bloc/user_progress_bloc.dart | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 2911280d..288f1233 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -130,7 +130,7 @@ class App extends StatelessWidget { BlocProvider( create: (_) => UserProgressBloc( causesService: locator(), - )..fetchUserState(), + )..init(), ), ], child: Builder( diff --git a/lib/models/action.dart b/lib/models/action.dart index 31f2a635..fb2e685b 100644 --- a/lib/models/action.dart +++ b/lib/models/action.dart @@ -137,7 +137,7 @@ class ListAction implements Explorable { required this.time, required BuiltList causes, required Api.ActionTypeEnum actionType, - }) : cause = Cause.fromApiModel(causes[0]), + }) : cause = Cause.fromApiModel(causes.first), type = getActionTypeFromSubtype(actionType); factory ListAction.fromApiModel( diff --git a/lib/models/campaign.dart b/lib/models/campaign.dart index 2886950e..2010043d 100644 --- a/lib/models/campaign.dart +++ b/lib/models/campaign.dart @@ -61,7 +61,7 @@ class ListCampaign implements Explorable { required this.title, required this.headerImage, required BuiltList causes, - }) : cause = Cause.fromApiModel(causes[0]); + }) : cause = Cause.fromApiModel(causes.first); ListCampaign.fromApiModel(Api.ListCampaign apiModel) : this.fromApiData( diff --git a/lib/models/learning.dart b/lib/models/learning.dart index 4a6c814d..fe20f72d 100644 --- a/lib/models/learning.dart +++ b/lib/models/learning.dart @@ -81,7 +81,7 @@ class LearningResource extends Explorable { ) : id = apiModel.id, title = apiModel.title, link = Uri.parse(apiModel.link), - cause = Cause.fromApiModel(apiModel.causes[0]), + cause = Cause.fromApiModel(apiModel.causes.first), type = getResourceTypeFromEnum(apiModel.learningResourceType), time = apiModel.time, createdAt = apiModel.createdAt; diff --git a/lib/ui/components/user_progress/bloc/user_progress_bloc.dart b/lib/ui/components/user_progress/bloc/user_progress_bloc.dart index f95564fb..4ead46c3 100644 --- a/lib/ui/components/user_progress/bloc/user_progress_bloc.dart +++ b/lib/ui/components/user_progress/bloc/user_progress_bloc.dart @@ -19,7 +19,7 @@ class UserProgressBloc extends Cubit { }); } - void fetchUserState() async { + void init() async { try { final userInfo = await _causesService.getUserInfo(); if (userInfo == null) {