fix: reload space course after updating course state event, wait for … (#4359)
* fix: reload space course after updating course state event, wait for course ID update in sync after returning from add course to space function * Update lib/pangea/course_settings/course_settings.dart Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
096567ecf6
commit
512d7f566d
3 changed files with 16 additions and 3 deletions
|
|
@ -292,6 +292,7 @@ class SpaceDetailsContent extends StatelessWidget {
|
|||
// the key forces a rebuild on this redirect
|
||||
key: ValueKey(controller.widget.activeTab),
|
||||
room: room,
|
||||
courseId: room.coursePlan?.uuid,
|
||||
),
|
||||
);
|
||||
case SpaceSettingsTabs.participants:
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ extension CoursePlanRoomExtension on Room {
|
|||
}
|
||||
|
||||
Future<void> addCourseToSpace(String courseId) async {
|
||||
if (coursePlan?.uuid == courseId) return;
|
||||
final future = waitForRoomInSync();
|
||||
await client.setRoomStateWithKey(
|
||||
id,
|
||||
PangeaEventTypes.coursePlan,
|
||||
|
|
@ -41,6 +43,9 @@ extension CoursePlanRoomExtension on Room {
|
|||
"uuid": courseId,
|
||||
},
|
||||
);
|
||||
if (coursePlan?.uuid != courseId) {
|
||||
await future;
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> launchActivityRoom(
|
||||
|
|
|
|||
|
|
@ -24,9 +24,15 @@ import 'package:fluffychat/pangea/events/constants/pangea_event_types.dart';
|
|||
|
||||
class CourseSettings extends StatefulWidget {
|
||||
final Room room;
|
||||
|
||||
/// The course ID to load, from the course plan event in the room.
|
||||
/// Separate from the room to trigger didUpdateWidget on change
|
||||
final String? courseId;
|
||||
|
||||
const CourseSettings({
|
||||
super.key,
|
||||
required this.room,
|
||||
required this.courseId,
|
||||
});
|
||||
|
||||
@override
|
||||
|
|
@ -48,13 +54,14 @@ class CourseSettingsState extends State<CourseSettings>
|
|||
@override
|
||||
void didUpdateWidget(covariant CourseSettings oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (oldWidget.room.id != widget.room.id) {
|
||||
if (oldWidget.room.id != widget.room.id ||
|
||||
oldWidget.courseId != widget.courseId) {
|
||||
_loadCourseInfo();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _loadCourseInfo() async {
|
||||
if (widget.room.coursePlan == null) {
|
||||
if (widget.courseId == null) {
|
||||
setState(() {
|
||||
course = null;
|
||||
loadingCourse = false;
|
||||
|
|
@ -65,7 +72,7 @@ class CourseSettingsState extends State<CourseSettings>
|
|||
}
|
||||
|
||||
setState(() => _loadingActivities = true);
|
||||
await loadCourse(widget.room.coursePlan!.uuid);
|
||||
await loadCourse(widget.courseId!);
|
||||
if (course != null) {
|
||||
await loadTopics();
|
||||
await loadAllActivities();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue