chore: show invite dialog on chat list init
This commit is contained in:
parent
59feca13f8
commit
adde62896b
2 changed files with 18 additions and 2 deletions
|
|
@ -46,6 +46,7 @@ import '../../widgets/matrix.dart';
|
|||
import 'package:fluffychat/utils/tor_stub.dart'
|
||||
if (dart.library.html) 'package:tor_detector_web/tor_detector_web.dart';
|
||||
|
||||
|
||||
enum PopupMenuAction {
|
||||
settings,
|
||||
invite,
|
||||
|
|
@ -668,6 +669,10 @@ class ChatListController extends State<ChatList>
|
|||
|
||||
_activeSpaceId =
|
||||
widget.activeSpaceId == 'clear' ? null : widget.activeSpaceId;
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_joinInvitedSpaces();
|
||||
});
|
||||
// Pangea#
|
||||
|
||||
super.initState();
|
||||
|
|
@ -684,6 +689,16 @@ class ChatListController extends State<ChatList>
|
|||
: setActiveSpace(widget.activeSpaceId!);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _joinInvitedSpaces() async {
|
||||
final invitedSpaces = Matrix.of(context).client.rooms.where(
|
||||
(r) => r.isSpace && r.membership == Membership.invite,
|
||||
);
|
||||
|
||||
for (final space in invitedSpaces) {
|
||||
await showInviteDialog(space, context);
|
||||
}
|
||||
}
|
||||
// Pangea#
|
||||
|
||||
@override
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
|||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import '../../common/utils/error_handler.dart';
|
||||
|
||||
Future<void> _showInviteDialog(Room room, BuildContext context) async {
|
||||
Future<void> showInviteDialog(Room room, BuildContext context) async {
|
||||
if (room.membership != Membership.invite) return;
|
||||
final acceptInvite = await showOkCancelAlertDialog(
|
||||
context: context,
|
||||
title: L10n.of(context).youreInvited,
|
||||
|
|
@ -79,7 +80,7 @@ void chatListHandleSpaceTap(
|
|||
justInputtedCode == space.classCode) {
|
||||
// do nothing
|
||||
} else {
|
||||
_showInviteDialog(space, context);
|
||||
showInviteDialog(space, context);
|
||||
}
|
||||
break;
|
||||
case Membership.leave:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue