fix: always initialize course info after fetching (#3907)
This commit is contained in:
parent
b45541d826
commit
29543ef4a3
3 changed files with 5 additions and 11 deletions
|
|
@ -56,11 +56,6 @@ class ActivityFinishedStatusMessage extends StatelessWidget {
|
|||
courseParent!.coursePlan!.uuid,
|
||||
);
|
||||
|
||||
if (coursePlan == null) {
|
||||
throw L10n.of(context).noCourseFound;
|
||||
}
|
||||
|
||||
await coursePlan.init();
|
||||
final activityId = controller.room.activityPlan!.activityId;
|
||||
final topicId = coursePlan.topicID(activityId);
|
||||
if (topicId == null) {
|
||||
|
|
|
|||
|
|
@ -61,14 +61,10 @@ class CoursePlanController extends State<CoursePlanBuilder> {
|
|||
});
|
||||
|
||||
course = await CoursePlansRepo.get(widget.courseId!);
|
||||
if (course == null) {
|
||||
widget.onNotFound?.call();
|
||||
} else {
|
||||
await course!.init();
|
||||
}
|
||||
|
||||
widget.onLoaded?.call(course!);
|
||||
} catch (e) {
|
||||
widget.onNotFound?.call();
|
||||
error = e;
|
||||
} finally {
|
||||
setState(() {
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ class CoursePlansRepo {
|
|||
await _courseStorage.write(_searchKey(filter), jsonList);
|
||||
}
|
||||
|
||||
static Future<CoursePlanModel?> get(String id) async {
|
||||
static Future<CoursePlanModel> get(String id) async {
|
||||
final cached = _getCached(id);
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
|
|
@ -113,6 +113,7 @@ class CoursePlansRepo {
|
|||
|
||||
final coursePlan = cmsCoursePlan.toCoursePlanModel();
|
||||
await _setCached(coursePlan);
|
||||
await coursePlan.init();
|
||||
completer.complete(coursePlan);
|
||||
return coursePlan;
|
||||
} catch (e) {
|
||||
|
|
@ -194,6 +195,8 @@ class CoursePlansRepo {
|
|||
coursePlans,
|
||||
);
|
||||
|
||||
final futures = coursePlans.map((c) => c.init());
|
||||
await Future.wait(futures);
|
||||
return coursePlans;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue