mirror of
				https://gitlab.com/comunic/comunicmobile
				synced 2025-11-04 12:14:11 +00:00 
			
		
		
		
	Can update conversation settings
This commit is contained in:
		@@ -3,6 +3,7 @@ import 'package:comunic/helpers/users_helper.dart';
 | 
			
		||||
import 'package:comunic/lists/users_list.dart';
 | 
			
		||||
import 'package:comunic/models/conversation.dart';
 | 
			
		||||
import 'package:comunic/models/new_conversation.dart';
 | 
			
		||||
import 'package:comunic/models/new_conversation_settings.dart';
 | 
			
		||||
import 'package:comunic/models/user.dart';
 | 
			
		||||
import 'package:comunic/ui/dialogs/color_picker_dialog.dart';
 | 
			
		||||
import 'package:comunic/ui/routes/main_route/main_route.dart';
 | 
			
		||||
@@ -85,6 +86,8 @@ class _UpdateConversationScreen extends State<UpdateConversationScreen> {
 | 
			
		||||
    _admins = _conversation.adminsID;
 | 
			
		||||
    _followConversation = _conversation.following;
 | 
			
		||||
    _canEveryoneAddMembers = _conversation.canEveryoneAddMembers;
 | 
			
		||||
 | 
			
		||||
    setState(() {});
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
@@ -289,45 +292,22 @@ class _UpdateConversationScreen extends State<UpdateConversationScreen> {
 | 
			
		||||
 | 
			
		||||
        MainController.of(context).popPage();
 | 
			
		||||
        MainController.of(context).openConversation(conversationID);
 | 
			
		||||
        return;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      // TODO : reimplement
 | 
			
		||||
      /* final settings = Conversation(
 | 
			
		||||
        id: isUpdating ? widget.initialSettings.id : 0,
 | 
			
		||||
        ownerID: isUpdating ? widget.initialSettings.ownerID : 0,
 | 
			
		||||
        name: _nameController.text,
 | 
			
		||||
      // Update conversation settings
 | 
			
		||||
      final newSettings = NewConversationsSettings(
 | 
			
		||||
        convID: _conversation.id,
 | 
			
		||||
        following: _followConversation,
 | 
			
		||||
        members: _members.usersID,
 | 
			
		||||
        isComplete: isAdmin,
 | 
			
		||||
        name: _nameController.text,
 | 
			
		||||
        canEveryoneAddMembers: _canEveryoneAddMembers,
 | 
			
		||||
        color: _color,
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
        // Give random value to these fields as they are ignored here
 | 
			
		||||
        lastActive: 0,
 | 
			
		||||
        sawLastMessage: true);
 | 
			
		||||
      await ConversationsHelper.updateConversation(newSettings);
 | 
			
		||||
 | 
			
		||||
    // Create the conversation
 | 
			
		||||
    var conversationID = settings.id;
 | 
			
		||||
    bool error = false;
 | 
			
		||||
    if (isUpdating)
 | 
			
		||||
      error = !(await ConversationsHelper().updateConversation(settings));
 | 
			
		||||
    else {
 | 
			
		||||
      conversationID = await ConversationsHelper().createConversation(settings);
 | 
			
		||||
      if (conversationID < 1) error = true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Check for errors
 | 
			
		||||
    if (error)
 | 
			
		||||
      return Scaffold.of(context).showSnackBar(SnackBar(
 | 
			
		||||
        content: Text(isUpdating
 | 
			
		||||
            ? tr("Could not update the conversation!")
 | 
			
		||||
            : tr("Could not create the conversation!")),
 | 
			
		||||
        duration: Duration(seconds: 1),
 | 
			
		||||
      ));
 | 
			
		||||
 | 
			
		||||
    // Open the conversation
 | 
			
		||||
 | 
			
		||||
    MainController.of(context).popPage();
 | 
			
		||||
    if (!isUpdating)
 | 
			
		||||
      MainController.of(context).openConversation(conversationID);*/
 | 
			
		||||
      MainController.of(context).popPage();
 | 
			
		||||
    } catch (e, s) {
 | 
			
		||||
      logError(e, s);
 | 
			
		||||
      snack(context, tr("Failed to update conversation settings!"));
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user