fix: fix needed participants copy (#4058)
This commit is contained in:
parent
8261a34f17
commit
d338d24a83
2 changed files with 9 additions and 7 deletions
|
|
@ -199,7 +199,7 @@ class ActivitySessionStartController extends State<ActivitySessionStartPage>
|
|||
if (mounted) setState(() => _selectedRoleId = id);
|
||||
}
|
||||
|
||||
Future<bool> courseHasEnoughParticipants() async {
|
||||
Future<int> neededCourseParticipants() async {
|
||||
final courseParticipants = await courseParent?.requestParticipants(
|
||||
[Membership.join, Membership.invite, Membership.knock],
|
||||
false,
|
||||
|
|
@ -214,7 +214,10 @@ class ActivitySessionStartController extends State<ActivitySessionStartPage>
|
|||
final addBotToAvailableUsers = !botInCourse && !isBotRoomMember;
|
||||
final availableParticipants =
|
||||
courseParticipants.length + (addBotToAvailableUsers ? 1 : 0);
|
||||
return availableParticipants >= (activity?.req.numberOfParticipants ?? 0);
|
||||
if (availableParticipants >= (activity?.req.numberOfParticipants ?? 0)) {
|
||||
return 0;
|
||||
}
|
||||
return (activity?.req.numberOfParticipants ?? 0) - availableParticipants;
|
||||
}
|
||||
|
||||
Future<void> _loadActivity() async {
|
||||
|
|
|
|||
|
|
@ -258,21 +258,20 @@ class _ActivityStartButtons extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
final hasActiveSession = controller.canJoinExistingSession;
|
||||
return FutureBuilder(
|
||||
future: controller.courseHasEnoughParticipants(),
|
||||
future: controller.neededCourseParticipants(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||
return const LinearProgressIndicator();
|
||||
}
|
||||
|
||||
final bool hasEnoughParticipants = snapshot.data ?? true;
|
||||
final int neededParticipants = snapshot.data ?? 0;
|
||||
final bool hasEnoughParticipants = neededParticipants <= 0;
|
||||
return Column(
|
||||
spacing: 16.0,
|
||||
children: [
|
||||
if (!hasEnoughParticipants) ...[
|
||||
Text(
|
||||
L10n.of(context).activityNeedsMembers(
|
||||
(controller.activity?.req.numberOfParticipants ?? 2) - 1,
|
||||
),
|
||||
L10n.of(context).activityNeedsMembers(neededParticipants),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
if (controller.courseParent?.canInvite ?? false)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue