feat: Enable E2EE by default for new rooms

This commit is contained in:
Krille Fear 2021-10-10 10:43:50 +02:00
commit 92523cb7b0
3 changed files with 37 additions and 17 deletions

View file

@ -20,9 +20,20 @@ class ProfileBottomSheet extends StatelessWidget {
}) : super(key: key);
void _startDirectChat(BuildContext context) async {
final client = Matrix.of(context).client;
final result = await showFutureLoadingDialog<String>(
context: context,
future: () => Matrix.of(context).client.startDirectChat(userId),
future: () async {
final roomId = await client.startDirectChat(userId);
if (client.getRoomById(roomId) == null) {
await client.onSync.stream.firstWhere(
(sync) => sync.rooms?.join?.containsKey(roomId) ?? false);
}
if (client.encryptionEnabled) {
await client.getRoomById(roomId).enableEncryption();
}
return roomId;
},
);
if (result.error == null) {
VRouter.of(context).toSegments(['rooms', result.result]);
@ -81,8 +92,10 @@ class ProfileBottomSheet extends StatelessWidget {
subtitle: Text(userId),
trailing: Icon(Icons.account_box_outlined),
),
Center(
child: FloatingActionButton.extended(
Container(
width: double.infinity,
padding: EdgeInsets.all(12),
child: ElevatedButton.icon(
onPressed: () => _startDirectChat(context),
label: Text(L10n.of(context).newChat),
icon: Icon(Icons.send_outlined),