1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-11-22 04:49:21 +00:00

Can cancel invitation

This commit is contained in:
Pierre HUBERT 2021-04-25 17:19:49 +02:00
parent 38d3f4de8d
commit 56f92173f2

View File

@ -3,6 +3,7 @@ import 'package:comunic/helpers/groups_helper.dart';
import 'package:comunic/helpers/users_helper.dart';
import 'package:comunic/lists/group_members_list.dart';
import 'package:comunic/lists/users_list.dart';
import 'package:comunic/models/group.dart';
import 'package:comunic/models/group_membership.dart';
import 'package:comunic/models/user.dart';
import 'package:comunic/ui/widgets/account_image_widget.dart';
@ -10,13 +11,15 @@ import 'package:comunic/ui/widgets/async_screen_widget.dart';
import 'package:comunic/utils/account_utils.dart';
import 'package:comunic/utils/conversations_utils.dart';
import 'package:comunic/utils/intl_utils.dart';
import 'package:comunic/utils/log_utils.dart';
import 'package:comunic/utils/ui_utils.dart';
import 'package:flutter/material.dart';
/// Forez directory screen
///
/// @author Pierre Hubert
enum _PopupMenuActions { PRIVATE_CONVERSATION }
enum _PopupMenuActions { PRIVATE_CONVERSATION, CANCEL_INVITATION }
class ForezDirectoryScreen extends StatefulWidget {
@override
@ -52,10 +55,20 @@ class _ForezDirectoryScreenState extends State<ForezDirectoryScreen> {
);
void _doPopupMenuAction(_PopupMenuActions action, User user) async {
try {
switch (action) {
case _PopupMenuActions.PRIVATE_CONVERSATION:
openPrivateConversation(context, user.id);
break;
case _PopupMenuActions.CANCEL_INVITATION:
await GroupsHelper.cancelInvitation(forezGroup.id, user.id);
_key.currentState.refresh();
break;
}
} catch (e, s) {
logError(e, s);
snack(context, tr("Error while processing action!"));
}
}
}
@ -89,6 +102,14 @@ class _ForezMemberTile extends StatelessWidget {
PopupMenuItem(
child: Text(tr("Private conversation")),
value: _PopupMenuActions.PRIVATE_CONVERSATION,
)
]..addAll(member.level == GroupMembershipLevel.INVITED &&
forezGroup.isAtLeastModerator
? [
PopupMenuItem(
child: Text(tr("Cancel invitation")),
value: _PopupMenuActions.CANCEL_INVITATION,
),
];
]
: []);
}