mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 21:09:21 +00:00
Fix rights issues
This commit is contained in:
parent
685565e031
commit
07adf8c2ca
@ -10,6 +10,7 @@ import 'package:comunic/ui/dialogs/pick_user_dialog.dart';
|
|||||||
import 'package:comunic/ui/widgets/account_image_widget.dart';
|
import 'package:comunic/ui/widgets/account_image_widget.dart';
|
||||||
import 'package:comunic/ui/widgets/async_screen_widget.dart';
|
import 'package:comunic/ui/widgets/async_screen_widget.dart';
|
||||||
import 'package:comunic/ui/widgets/comunic_back_button_widget.dart';
|
import 'package:comunic/ui/widgets/comunic_back_button_widget.dart';
|
||||||
|
import 'package:comunic/utils/account_utils.dart';
|
||||||
import 'package:comunic/utils/intl_utils.dart';
|
import 'package:comunic/utils/intl_utils.dart';
|
||||||
import 'package:comunic/utils/ui_utils.dart';
|
import 'package:comunic/utils/ui_utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -157,7 +158,9 @@ enum _MemberMenuOptions { CHANGE_LEVEL, DELETE }
|
|||||||
class __GroupMembershipTileState extends State<_GroupMembershipTile> {
|
class __GroupMembershipTileState extends State<_GroupMembershipTile> {
|
||||||
int get groupID => widget.membership.groupID;
|
int get groupID => widget.membership.groupID;
|
||||||
|
|
||||||
int get userID => widget.membership.userID;
|
int get memberID => widget.membership.userID;
|
||||||
|
|
||||||
|
bool get _isCurrentUser => widget.membership.userID == userID();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -203,7 +206,7 @@ class __GroupMembershipTileState extends State<_GroupMembershipTile> {
|
|||||||
// Change membership level
|
// Change membership level
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
child: Text(tr("Change level")),
|
child: Text(tr("Change level")),
|
||||||
enabled: widget.group.isAdmin,
|
enabled: !_isCurrentUser && widget.group.isAdmin,
|
||||||
value: _MemberMenuOptions.CHANGE_LEVEL,
|
value: _MemberMenuOptions.CHANGE_LEVEL,
|
||||||
),
|
),
|
||||||
|
|
||||||
@ -211,6 +214,7 @@ class __GroupMembershipTileState extends State<_GroupMembershipTile> {
|
|||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
child: Text(tr("Remove")),
|
child: Text(tr("Remove")),
|
||||||
value: _MemberMenuOptions.DELETE,
|
value: _MemberMenuOptions.DELETE,
|
||||||
|
enabled: !_isCurrentUser,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
onSelected: _handleMenu,
|
onSelected: _handleMenu,
|
||||||
@ -240,7 +244,7 @@ class __GroupMembershipTileState extends State<_GroupMembershipTile> {
|
|||||||
|
|
||||||
if (newLevel == null) return;
|
if (newLevel == null) return;
|
||||||
|
|
||||||
await GroupsHelper.setNewLevel(groupID, userID, newLevel);
|
await GroupsHelper.setNewLevel(groupID, memberID, newLevel);
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
print("Could not change group membership level! $e\n$s");
|
print("Could not change group membership level! $e\n$s");
|
||||||
showSimpleSnack(context, tr("Could not change group membership level!"));
|
showSimpleSnack(context, tr("Could not change group membership level!"));
|
||||||
@ -256,7 +260,7 @@ class __GroupMembershipTileState extends State<_GroupMembershipTile> {
|
|||||||
message: tr("Do you really want to remove this membership ?")))
|
message: tr("Do you really want to remove this membership ?")))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
await GroupsHelper.removeMemberFromGroup(groupID, userID);
|
await GroupsHelper.removeMemberFromGroup(groupID, memberID);
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
print("Could not remove membership! $e\n$s");
|
print("Could not remove membership! $e\n$s");
|
||||||
showSimpleSnack(context, tr("Could not remove this membership!"));
|
showSimpleSnack(context, tr("Could not remove this membership!"));
|
||||||
@ -275,7 +279,7 @@ class __GroupMembershipTileState extends State<_GroupMembershipTile> {
|
|||||||
|
|
||||||
void _cancelMembership() async {
|
void _cancelMembership() async {
|
||||||
try {
|
try {
|
||||||
await GroupsHelper.cancelInvitation(groupID, userID);
|
await GroupsHelper.cancelInvitation(groupID, memberID);
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
print("Could not cancel invitation! $e\n$s");
|
print("Could not cancel invitation! $e\n$s");
|
||||||
showSimpleSnack(context, tr("Could not cancel invitation!"));
|
showSimpleSnack(context, tr("Could not cancel invitation!"));
|
||||||
@ -304,7 +308,7 @@ class __GroupMembershipTileState extends State<_GroupMembershipTile> {
|
|||||||
|
|
||||||
void _respondRequest(bool accept) async {
|
void _respondRequest(bool accept) async {
|
||||||
try {
|
try {
|
||||||
await GroupsHelper.respondRequest(groupID, userID, accept);
|
await GroupsHelper.respondRequest(groupID, memberID, accept);
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
print("Could not respond to membership request! $e\n$s");
|
print("Could not respond to membership request! $e\n$s");
|
||||||
showSimpleSnack(context, tr("Could not respond to membership request!"));
|
showSimpleSnack(context, tr("Could not respond to membership request!"));
|
||||||
|
Loading…
Reference in New Issue
Block a user