fix: join public room

This commit is contained in:
Christian Pauly 2020-12-06 14:54:58 +01:00
parent 36c8a8b195
commit 30883e57a2

View File

@ -66,15 +66,22 @@ class _DiscoverPageState extends State<DiscoverPage> {
});
}
Future<String> _joinRoomAndWait(BuildContext context, String roomId) async {
final newRoomId = await Matrix.of(context).client.joinRoomOrAlias(roomId);
if (Matrix.of(context).client.getRoomById(newRoomId) == null) {
Future<String> _joinRoomAndWait(
BuildContext context,
String roomId,
String alias,
) async {
if (Matrix.of(context).client.getRoomById(roomId) != null) {
return roomId;
}
final newRoomId = await Matrix.of(context)
.client
.joinRoomOrAlias(alias?.isNotEmpty ?? false ? alias : roomId);
await Matrix.of(context)
.client
.onRoomUpdate
.stream
.firstWhere((r) => r.id == newRoomId);
}
return newRoomId;
}
@ -88,8 +95,13 @@ class _DiscoverPageState extends State<DiscoverPage> {
OkCancelResult.cancel) {
return;
}
final success = await SimpleDialogs(context)
.tryRequestWithLoadingDialog(_joinRoomAndWait(context, room.roomId));
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
_joinRoomAndWait(
context,
room.roomId,
room.canonicalAlias ?? room.aliases.first,
),
);
if (success != false) {
await Navigator.of(context).push(
AppRoute.defaultRoute(