fix: Join public room

This commit is contained in:
Krille 2023-03-15 19:39:05 +01:00
parent f24b3ee09b
commit 511dd41d30

View File

@ -29,23 +29,33 @@ class PublicRoomBottomSheet extends StatelessWidget {
void _joinRoom(BuildContext context) async { void _joinRoom(BuildContext context) async {
final client = Matrix.of(context).client; final client = Matrix.of(context).client;
final chunk = this.chunk;
final navigator = Navigator.of(context);
final router = VRouter.of(context);
final result = await showFutureLoadingDialog<String>( final result = await showFutureLoadingDialog<String>(
context: context, context: context,
future: () => chunk?.joinRule == 'knock' future: () async {
? client.knockRoom(chunk!.roomId) if (chunk != null && client.getRoomById(chunk.roomId) != null) {
: client.joinRoom(roomAlias ?? chunk!.roomId), return chunk.roomId;
}
final roomId = chunk != null && chunk.joinRule == 'knock'
? await client.knockRoom(chunk.roomId)
: await client.joinRoom(roomAlias ?? chunk!.roomId);
if (client.getRoomById(roomId) == null) {
await client.onSync.stream.firstWhere(
(sync) => sync.rooms?.join?.containsKey(roomId) ?? false,
);
}
return roomId;
},
); );
if (result.error == null) { if (result.error == null) {
if (client.getRoomById(result.result!) == null) { navigator.pop();
await client.onSync.stream.firstWhere(
(sync) => sync.rooms?.join?.containsKey(result.result) ?? false,
);
}
// don't open the room if the joined room is a space // don't open the room if the joined room is a space
if (!client.getRoomById(result.result!)!.isSpace) { if (!client.getRoomById(result.result!)!.isSpace) {
VRouter.of(context).toSegments(['rooms', result.result!]); router.toSegments(['rooms', result.result!]);
} }
Navigator.of(context, rootNavigator: false).pop();
return; return;
} }
} }