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

Fix issue on conversation update

This commit is contained in:
Pierre HUBERT 2019-05-01 11:30:55 +02:00
parent 0b1e579a41
commit 9d20c407fc
3 changed files with 20 additions and 2 deletions

View File

@ -58,7 +58,14 @@ class ConversationsHelper {
final response = await request.exec();
return response.code == 200;
if(response.code != 200)
return false;
//Delete old conversation entry from the database
await _conversationsDatabaseHelper.delete(settings.id);
// Success
return true;
}
/// Delete a conversation specified by its [id]

View File

@ -46,6 +46,17 @@ abstract class ModelDatabaseHelper<T extends CacheModel> {
return null;
}
/// Delete an entry from the database with a specified [id]
///
/// Return true if at least one entry was deleted / false else
Future<bool> delete(int id) async {
return await (await DatabaseHelper.get()).delete(
tableName(),
where: '${BaseTableContract.C_ID} = ?',
whereArgs: [id],
) > 0;
}
/// Get all the entries from the table
Future<List<T>> getAll() async {
List<Map> maps = await (await DatabaseHelper.get()).query(tableName());

View File

@ -143,13 +143,13 @@ class _UpdateConversationScreen extends State<UpdateConversationScreen> {
Future<void> _submitForm() async {
final settings = Conversation(
id: isUpdating ? widget.initialSettings.id : 0,
ownerID: isUpdating ? widget.initialSettings.ownerID : 0,
name: _nameController.text,
following: _followConversation,
members: _members.usersID,
// Give random value to these fields as they are ignored here
lastActive: 0,
ownerID: 0,
sawLastMessage: true);
// Create the conversation