chore: Follow up join space children
This commit is contained in:
parent
c7b9acfcdf
commit
76b7fbf36f
2 changed files with 25 additions and 35 deletions
|
|
@ -11,10 +11,12 @@ import 'package:matrix/matrix.dart';
|
|||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/pages/chat_list/chat_list_item.dart';
|
||||
import 'package:fluffychat/pages/chat_list/search_title.dart';
|
||||
import 'package:fluffychat/utils/adaptive_bottom_sheet.dart';
|
||||
import 'package:fluffychat/utils/localized_exception_extension.dart';
|
||||
import 'package:fluffychat/utils/stream_extension.dart';
|
||||
import 'package:fluffychat/widgets/avatar.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:fluffychat/widgets/public_room_bottom_sheet.dart';
|
||||
|
||||
enum AddRoomType { chat, subspace }
|
||||
|
||||
|
|
@ -95,38 +97,23 @@ class _SpaceViewState extends State<SpaceView> {
|
|||
final client = Matrix.of(context).client;
|
||||
final space = client.getRoomById(widget.spaceId);
|
||||
|
||||
final consent = await showOkCancelAlertDialog(
|
||||
final joined = await showAdaptiveBottomSheet<bool>(
|
||||
context: context,
|
||||
title: item.name ?? item.canonicalAlias ?? L10n.of(context)!.emptyChat,
|
||||
message: item.topic,
|
||||
okLabel: L10n.of(context)!.joinRoom,
|
||||
cancelLabel: L10n.of(context)!.cancel,
|
||||
builder: (_) => PublicRoomBottomSheet(
|
||||
outerContext: context,
|
||||
chunk: item,
|
||||
via: space?.spaceChildren
|
||||
.firstWhereOrNull(
|
||||
(child) => child.roomId == item.roomId,
|
||||
)
|
||||
?.via,
|
||||
),
|
||||
);
|
||||
if (consent != OkCancelResult.ok) return;
|
||||
if (!mounted) return;
|
||||
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () async {
|
||||
await client.joinRoom(
|
||||
item.roomId,
|
||||
serverName: space?.spaceChildren
|
||||
.firstWhereOrNull(
|
||||
(child) => child.roomId == item.roomId,
|
||||
)
|
||||
?.via,
|
||||
);
|
||||
if (client.getRoomById(item.roomId) == null) {
|
||||
// Wait for room actually appears in sync
|
||||
await client.waitForRoomInSync(item.roomId, join: true);
|
||||
}
|
||||
},
|
||||
);
|
||||
if (!mounted) return;
|
||||
|
||||
setState(() {
|
||||
_discoveredChildren.remove(item);
|
||||
});
|
||||
if (mounted && joined == true) {
|
||||
setState(() {
|
||||
_discoveredChildren.remove(item);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void _onSpaceAction(SpaceActions action) async {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue