|
|
|
|
@ -17,7 +17,6 @@ import 'package:future_loading_dialog/future_loading_dialog.dart';
|
|
|
|
|
import 'package:matrix/matrix.dart';
|
|
|
|
|
|
|
|
|
|
import '../../widgets/matrix.dart';
|
|
|
|
|
import '../utils/bot_name.dart';
|
|
|
|
|
import '../utils/firebase_analytics.dart';
|
|
|
|
|
import 'base_controller.dart';
|
|
|
|
|
|
|
|
|
|
@ -69,41 +68,6 @@ class ClassController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// if not bot chat return
|
|
|
|
|
/// if bot chat, get pangeaClassContext
|
|
|
|
|
/// for all classes not in pangeaClassContext, add bot chat to that class
|
|
|
|
|
/// PTODO - add analytics bot to all chats and have that do this work
|
|
|
|
|
Future<List<Room>> addDirectChatsToClasses(Room room) async {
|
|
|
|
|
if (!room.isDirectChat) return [];
|
|
|
|
|
final List<String> existingParentsIds =
|
|
|
|
|
room.pangeaSpaceParents.map((e) => e.id).toList();
|
|
|
|
|
final List<Room> spaces = _pangeaController.matrixState.client.spacesImIn;
|
|
|
|
|
|
|
|
|
|
//make sure we have the latest participants
|
|
|
|
|
await Future.wait(spaces.map((e) => e.requestParticipants()));
|
|
|
|
|
|
|
|
|
|
//get spaces where,
|
|
|
|
|
//other chat participant is the bot OR is in the space AND the chat is not
|
|
|
|
|
final List<Room> spacesToAdd = spaces
|
|
|
|
|
.where(
|
|
|
|
|
(s) =>
|
|
|
|
|
(room.directChatMatrixID == BotName.byEnvironment ||
|
|
|
|
|
s
|
|
|
|
|
.getParticipants()
|
|
|
|
|
.map(
|
|
|
|
|
(u) => u.id,
|
|
|
|
|
)
|
|
|
|
|
.contains(room.directChatMatrixID)) &&
|
|
|
|
|
!existingParentsIds.contains(s.id),
|
|
|
|
|
)
|
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
|
|
//set the space child for each space
|
|
|
|
|
return Future.wait(
|
|
|
|
|
spacesToAdd.map((s) => s.setSpaceChild(room.id, suggested: true)),
|
|
|
|
|
).then((value) => spaces);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> joinClasswithCode(BuildContext context, String classCode) async {
|
|
|
|
|
try {
|
|
|
|
|
final QueryPublicRoomsResponse queryPublicRoomsResponse =
|
|
|
|
|
|