chore: on invite, also invite to course parent (#4268)
This commit is contained in:
parent
53f601dbad
commit
2c3a19bb67
4 changed files with 32 additions and 14 deletions
|
|
@ -5166,7 +5166,8 @@
|
|||
},
|
||||
"pingParticipants": "Ping course participants",
|
||||
"playWithBot": "Play with Pangea Bot",
|
||||
"inviteFriends": "Invite friends",
|
||||
"inviteFriendsToActivity": "Invite friends to activity",
|
||||
"inviteFriendsToActivityCourse": "Invite friends to activity and course",
|
||||
"waitNotDone": "Wait I’m not done!",
|
||||
"waitingForOthersToFinish": "Waiting for the rest to finish up...",
|
||||
"saveToCompletedActivities": "Save to completed activities",
|
||||
|
|
|
|||
|
|
@ -250,8 +250,12 @@ class ActivitySessionStartView extends StatelessWidget {
|
|||
MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
L10n.of(context)
|
||||
.inviteFriends,
|
||||
controller.courseParent !=
|
||||
null
|
||||
? L10n.of(context)
|
||||
.inviteFriendsToActivityCourse
|
||||
: L10n.of(context)
|
||||
.inviteFriendsToActivity,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import 'package:collection/collection.dart';
|
|||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pangea/activity_sessions/activity_room_extension.dart';
|
||||
import 'package:fluffychat/pangea/bot/utils/bot_name.dart';
|
||||
import 'package:fluffychat/pangea/chat_settings/pages/pangea_invitation_selection_view.dart';
|
||||
import 'package:fluffychat/pangea/common/config/environment.dart';
|
||||
|
|
@ -377,12 +378,33 @@ class PangeaInvitationSelectionController
|
|||
});
|
||||
}
|
||||
|
||||
void inviteAction(BuildContext context, String id, String displayname) async {
|
||||
void inviteAction(String userID) async {
|
||||
final room = Matrix.of(context).client.getRoomById(widget.roomId)!;
|
||||
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => room.invite(id),
|
||||
future: () async {
|
||||
await room.invite(userID);
|
||||
if (room.courseParent != null && room.courseParent!.canInvite) {
|
||||
await room.courseParent!.requestParticipants(
|
||||
[Membership.join, Membership.invite],
|
||||
false,
|
||||
true,
|
||||
);
|
||||
|
||||
final existingParticipant = room.courseParent!
|
||||
.getParticipants()
|
||||
.firstWhereOrNull((u) => u.id == userID);
|
||||
|
||||
if (existingParticipant == null ||
|
||||
![
|
||||
Membership.invite,
|
||||
Membership.join,
|
||||
].contains(existingParticipant.membership)) {
|
||||
await room.courseParent!.invite(userID);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
if (success.error == null) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
|
|
|
|||
|
|
@ -168,12 +168,7 @@ class PangeaInvitationSelectionView extends StatelessWidget {
|
|||
controller.foundProfiles[i].userId,
|
||||
),
|
||||
onTap: () => controller.inviteAction(
|
||||
context,
|
||||
controller.foundProfiles[i].userId,
|
||||
controller.foundProfiles[i].displayName ??
|
||||
controller
|
||||
.foundProfiles[i].userId.localpart ??
|
||||
L10n.of(context).user,
|
||||
),
|
||||
controller: controller,
|
||||
),
|
||||
|
|
@ -259,11 +254,7 @@ class PangeaInvitationSelectionView extends StatelessWidget {
|
|||
isMember:
|
||||
participants.contains(contacts[i].id),
|
||||
onTap: () => controller.inviteAction(
|
||||
context,
|
||||
contacts[i].id,
|
||||
contacts[i].displayName ??
|
||||
contacts[i].id.localpart ??
|
||||
L10n.of(context).user,
|
||||
),
|
||||
controller: controller,
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue