4354 room stuck indefinitely loading (#4357)
* fix: stop loading course if course plan provider if courseId is null * don't allow padding of null string to loadCoursePlan
This commit is contained in:
parent
173ac562a2
commit
096567ecf6
2 changed files with 23 additions and 13 deletions
|
|
@ -99,4 +99,14 @@ mixin CoursePlanProvider<T extends StatefulWidget> on State<T> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> loadAllActivities() async {
|
||||
if (course == null) return;
|
||||
|
||||
final futures = <Future>[];
|
||||
for (final topicId in course!.topicIds) {
|
||||
futures.add(loadActivity(topicId));
|
||||
}
|
||||
await Future.wait(futures);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,34 +42,34 @@ class CourseSettingsState extends State<CourseSettings>
|
|||
void initState() {
|
||||
super.initState();
|
||||
_loadSummaries();
|
||||
if (widget.room.coursePlan != null) {
|
||||
_loadCourseInfo();
|
||||
}
|
||||
_loadCourseInfo();
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant CourseSettings oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.room.id != widget.room.id) {
|
||||
if (widget.room.coursePlan != null) {
|
||||
_loadCourseInfo();
|
||||
}
|
||||
_loadCourseInfo();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _loadCourseInfo() async {
|
||||
if (widget.room.coursePlan == null) {
|
||||
setState(() {
|
||||
course = null;
|
||||
loadingCourse = false;
|
||||
loadingTopics = false;
|
||||
_loadingActivities = false;
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
setState(() => _loadingActivities = true);
|
||||
await loadCourse(widget.room.coursePlan!.uuid);
|
||||
if (course != null) {
|
||||
await loadTopics();
|
||||
|
||||
final futures = <Future>[];
|
||||
for (final topicId in course!.topicIds) {
|
||||
futures.add(loadActivity(topicId));
|
||||
}
|
||||
await Future.wait(futures);
|
||||
await loadAllActivities();
|
||||
}
|
||||
|
||||
if (mounted) setState(() => _loadingActivities = false);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue