mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-19 10:39:26 +01:00
fix: join public room
This commit is contained in:
parent
36c8a8b195
commit
30883e57a2
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user