Skip to content

Commit 222f63d

Browse files
committed
auto start class when owner joins an idle room
1 parent d93073b commit 222f63d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

app/src/main/java/io/agora/flat/ui/activity/play/ClassRoomViewModel.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class ClassRoomViewModel @Inject constructor(
161161
joinBoard()
162162
syncInitState()
163163
observerUserState()
164-
if (quickStart) startClass()
164+
checkAndStartClassAsOwner()
165165
}
166166
}
167167
}
@@ -631,6 +631,15 @@ class ClassRoomViewModel @Inject constructor(
631631
}
632632
}
633633

634+
private fun checkAndStartClassAsOwner() {
635+
val state = _state.value ?: return
636+
637+
if (state.isOwner && state.roomStatus == RoomStatus.Idle) {
638+
logger.d("Owner joined an Idle room, triggering startClass...")
639+
startClass()
640+
}
641+
}
642+
634643
private fun startClass() {
635644
viewModelScope.launch {
636645
val state = _state.value ?: return@launch

0 commit comments

Comments
 (0)