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:
ggurdin 2025-10-13 13:30:55 -04:00 committed by GitHub
parent 173ac562a2
commit 096567ecf6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 13 deletions

View file

@ -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);
}
}

View file

@ -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);
}