mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-03 19:54:12 +00:00 
			
		
		
		
	Can update admin status of a user
This commit is contained in:
		@@ -63,7 +63,9 @@ class _UpdateConversationScreen extends State<UpdateConversationScreen> {
 | 
			
		||||
 | 
			
		||||
  get isAdmin => !isUpdating || _conversation.isAdmin;
 | 
			
		||||
 | 
			
		||||
  bool get _canAddMembers => isAdmin || _conversation.canEveryoneAddMembers;
 | 
			
		||||
  bool get _canAddMembers =>
 | 
			
		||||
      (isAdmin || _conversation.canEveryoneAddMembers) &&
 | 
			
		||||
      (!isUpdating || !_conversation.isManaged);
 | 
			
		||||
 | 
			
		||||
  get _isValid => _members.length > 0;
 | 
			
		||||
 | 
			
		||||
@@ -221,7 +223,7 @@ class _UpdateConversationScreen extends State<UpdateConversationScreen> {
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
      case _MembersMenuChoices.TOGGLE_ADMIN_STATUS:
 | 
			
		||||
        // TODO: Handle this case.
 | 
			
		||||
        _toggleAdminStatus(user);
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
@@ -255,6 +257,23 @@ class _UpdateConversationScreen extends State<UpdateConversationScreen> {
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  void _toggleAdminStatus(User user) async {
 | 
			
		||||
    try {
 | 
			
		||||
      final setAdmin = !_admins.contains(user.id);
 | 
			
		||||
      await ConversationsHelper.setAdmin(_conversation.id, user.id, setAdmin);
 | 
			
		||||
 | 
			
		||||
      setState(() {
 | 
			
		||||
        if (!setAdmin)
 | 
			
		||||
          _admins.remove(user.id);
 | 
			
		||||
        else
 | 
			
		||||
          _admins.add(user.id);
 | 
			
		||||
      });
 | 
			
		||||
    } catch (e, s) {
 | 
			
		||||
      logError(e, s);
 | 
			
		||||
      snack(context, tr("Failed to toggle admin status of user!"));
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /// Submit the conversation
 | 
			
		||||
  Future<void> _submitForm() async {
 | 
			
		||||
    try {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user