From 1b5169eb56c7df754384bd5d443b444828f376d8 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sun, 26 Apr 2020 14:02:57 +0200 Subject: [PATCH] Add new conversation property --- lib/helpers/conversations_helper.dart | 1 + lib/helpers/database/database_contract.dart | 7 ++++--- lib/helpers/database/database_helper.dart | 3 ++- lib/models/conversation.dart | 7 +++++++ lib/ui/screens/update_conversation_screen.dart | 2 ++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/helpers/conversations_helper.dart b/lib/helpers/conversations_helper.dart index 2b7781f..3053f41 100644 --- a/lib/helpers/conversations_helper.dart +++ b/lib/helpers/conversations_helper.dart @@ -228,6 +228,7 @@ class ConversationsHelper { following: map["following"] == 1, sawLastMessage: map["saw_last_message"] == 1, members: List.from(map["members"]), + canEveryoneAddMembers: map["canEveryoneAddMembers"], callCapabilities: map["can_have_video_call"] ? CallCapabilities.VIDEO : (map["can_have_call"] diff --git a/lib/helpers/database/database_contract.dart b/lib/helpers/database/database_contract.dart index e233c67..537d4bf 100644 --- a/lib/helpers/database/database_contract.dart +++ b/lib/helpers/database/database_contract.dart @@ -4,7 +4,7 @@ /// Main information class DatabaseContract { - static const DATABASE_VERSION = 1; + static const DATABASE_VERSION = 2; static const DATABASE_FILE_NAME = "database.sqlite"; } @@ -19,7 +19,7 @@ abstract class UserTableContract { static const C_ID = BaseTableContract.C_ID; static const C_FIRST_NAME = "first_name"; static const C_LAST_NAME = "last_name"; - static const C_VISIBILITY = "visibility"; + static const C_VISIBILITY = "visibility"; static const C_VIRTUAL_DIRECTORY = "virtual_directory"; static const C_ACCOUNT_IMAGE_URL = "account_image_url"; } @@ -34,6 +34,7 @@ abstract class ConversationTableContract { static const C_FOLLOWING = "following"; static const C_SAW_LAST_MESSAGE = "saw_last_message"; static const C_MEMBERS = "members"; + static const C_CAN_EVERYONE_ADD_MEMBERS = "can_everyone_add_members"; } /// Conversations messages table contract @@ -55,4 +56,4 @@ abstract class FriendsListTableContract { static const C_LAST_ACTIVE = "last_active"; static const C_FOLLOWING = "following"; static const C_CAN_POST_TEXTS = "can_post_texts"; -} \ No newline at end of file +} diff --git a/lib/helpers/database/database_helper.dart b/lib/helpers/database/database_helper.dart index 598209a..d34eca4 100644 --- a/lib/helpers/database/database_helper.dart +++ b/lib/helpers/database/database_helper.dart @@ -81,7 +81,8 @@ abstract class DatabaseHelper { "${ConversationTableContract.C_NAME} TEXT, " "${ConversationTableContract.C_FOLLOWING} INTEGER, " "${ConversationTableContract.C_SAW_LAST_MESSAGE} INTEGER, " - "${ConversationTableContract.C_MEMBERS} TEXT" + "${ConversationTableContract.C_MEMBERS} TEXT, " + "${ConversationTableContract.C_CAN_EVERYONE_ADD_MEMBERS} INTEGER" ")"); // Create conversation messages table diff --git a/lib/models/conversation.dart b/lib/models/conversation.dart index 8cdecb2..d703186 100644 --- a/lib/models/conversation.dart +++ b/lib/models/conversation.dart @@ -17,6 +17,7 @@ class Conversation extends CacheModel implements Comparable { final bool following; final bool sawLastMessage; final List members; + final bool canEveryoneAddMembers; final CallCapabilities callCapabilities; final bool isHavingCall; @@ -28,6 +29,7 @@ class Conversation extends CacheModel implements Comparable { @required this.following, @required this.sawLastMessage, @required this.members, + @required this.canEveryoneAddMembers, this.callCapabilities = CallCapabilities.NONE, this.isHavingCall = false, }) : assert(id != null), @@ -36,6 +38,7 @@ class Conversation extends CacheModel implements Comparable { assert(following != null), assert(sawLastMessage != null), assert(members != null), + assert(canEveryoneAddMembers != null), assert(callCapabilities != null), assert(isHavingCall != null), super(id: id); @@ -55,6 +58,8 @@ class Conversation extends CacheModel implements Comparable { sawLastMessage = map[ConversationTableContract.C_SAW_LAST_MESSAGE] == 1, members = listToIntList(map[ConversationTableContract.C_MEMBERS].split(",")), + canEveryoneAddMembers = + map[ConversationTableContract.C_CAN_EVERYONE_ADD_MEMBERS] == 1, // By default, we can not do any call callCapabilities = CallCapabilities.NONE, @@ -71,6 +76,8 @@ class Conversation extends CacheModel implements Comparable { ConversationTableContract.C_FOLLOWING: following ? 1 : 0, ConversationTableContract.C_SAW_LAST_MESSAGE: sawLastMessage ? 1 : 0, ConversationTableContract.C_MEMBERS: members.join(","), + ConversationTableContract.C_CAN_EVERYONE_ADD_MEMBERS: + canEveryoneAddMembers ? 1 : 0 }; } diff --git a/lib/ui/screens/update_conversation_screen.dart b/lib/ui/screens/update_conversation_screen.dart index 109303a..101f492 100644 --- a/lib/ui/screens/update_conversation_screen.dart +++ b/lib/ui/screens/update_conversation_screen.dart @@ -31,6 +31,7 @@ class _UpdateConversationScreen extends State { TextEditingController _nameController = TextEditingController(); UsersList _members = UsersList(); bool _followConversation = true; + bool _canEveryoneAddMembers = true; get isUpdating => widget.initialSettings != null; @@ -147,6 +148,7 @@ class _UpdateConversationScreen extends State { name: _nameController.text, following: _followConversation, members: _members.usersID, + canEveryoneAddMembers: _canEveryoneAddMembers, // Give random value to these fields as they are ignored here lastActive: 0,