Doesn't add welcome chat to subspace

This commit is contained in:
Kelrap 2024-07-16 13:59:45 -04:00
parent efa325fa43
commit 2fbc4e2016
2 changed files with 20 additions and 14 deletions

View file

@ -147,7 +147,7 @@ class LoginView extends StatelessWidget {
controller.showPassword
? Icons.visibility_off_outlined
: Icons.visibility_outlined,
color: Colors.black,
// color: Colors.black,
),
),
),

View file

@ -198,14 +198,18 @@ class NewSpaceController extends State<NewSpace> {
if (capacity != null && space != null) {
space.updateRoomCapacity(capacity);
}
final newChatRoomId = await Matrix.of(context).client.createGroupChat(
enableEncryption: false,
preset: sdk.CreateRoomPreset.publicChat,
// Welcome chat name is '[space name acronym]: Welcome Chat'
groupName:
'${nameController.text.trim().split(RegExp(r"\s+")).map((s) => s[0]).join()}: ${L10n.of(context)!.classWelcomeChat}',
);
GoogleAnalytics.createChat(newChatRoomId);
// If space has no parents, add welcome chat
String? newChatRoomId;
if (space?.pangeaSpaceParents.isEmpty ?? false) {
newChatRoomId = await Matrix.of(context).client.createGroupChat(
enableEncryption: false,
preset: sdk.CreateRoomPreset.publicChat,
// Welcome chat name is '[space name acronym]: Welcome Chat'
groupName:
'${nameController.text.trim().split(RegExp(r"\s+")).map((s) => s[0]).join()}: ${L10n.of(context)!.classWelcomeChat}',
);
GoogleAnalytics.createChat(newChatRoomId);
}
final Room? room = Matrix.of(context).client.getRoomById(spaceId);
if (room == null) {
@ -217,11 +221,13 @@ class NewSpaceController extends State<NewSpace> {
return;
}
room.setSpaceChild(newChatRoomId, suggested: true);
GoogleAnalytics.addParent(
newChatRoomId,
room.classCode,
);
if (newChatRoomId != null) {
room.setSpaceChild(newChatRoomId, suggested: true);
GoogleAnalytics.addParent(
newChatRoomId,
room.classCode,
);
}
GoogleAnalytics.createClass(room.name, room.classCode);
try {