mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 09:45:14 +00:00
fix: Join public room
This commit is contained in:
parent
ae99606531
commit
841c081e08
1 changed files with 20 additions and 10 deletions
|
@ -29,23 +29,33 @@ class PublicRoomBottomSheet extends StatelessWidget {
|
|||
|
||||
void _joinRoom(BuildContext context) async {
|
||||
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>(
|
||||
context: context,
|
||||
future: () => chunk?.joinRule == 'knock'
|
||||
? client.knockRoom(chunk!.roomId)
|
||||
: client.joinRoom(roomAlias ?? chunk!.roomId),
|
||||
future: () async {
|
||||
if (chunk != null && client.getRoomById(chunk.roomId) != null) {
|
||||
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 (client.getRoomById(result.result!) == null) {
|
||||
await client.onSync.stream.firstWhere(
|
||||
(sync) => sync.rooms?.join?.containsKey(result.result) ?? false,
|
||||
);
|
||||
}
|
||||
navigator.pop();
|
||||
// don't open the room if the joined room is a space
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue