mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 21:09:21 +00:00
38 lines
1.2 KiB
Dart
38 lines
1.2 KiB
Dart
import 'package:comunic/helpers/database/database_contract.dart';
|
|
import 'package:comunic/helpers/database/model_database_helper.dart';
|
|
import 'package:comunic/lists/conversation_messages_list.dart';
|
|
import 'package:comunic/models/conversation_message.dart';
|
|
|
|
/// Conversation messages database helper
|
|
///
|
|
/// @author Pierre HUBERT
|
|
|
|
class ConversationMessagesDatabaseHelper
|
|
extends ModelDatabaseHelper<ConversationMessage> {
|
|
@override
|
|
ConversationMessage initializeFromMap(Map<String, dynamic> map) {
|
|
return ConversationMessage.fromMap(map);
|
|
}
|
|
|
|
@override
|
|
String tableName() {
|
|
return ConversationsMessagesTableContract.TABLE_NAME;
|
|
}
|
|
|
|
/// Get all the message cached for a given conversation
|
|
Future<ConversationMessagesList> getAllMessagesConversations(
|
|
int conversationID,
|
|
{int lastMessageID = 0}) async {
|
|
final list = await getMultiple(
|
|
where: "${ConversationsMessagesTableContract.C_CONVERSATION_ID} = ? "
|
|
"AND ${BaseTableContract.C_ID} > ?",
|
|
whereArgs: [conversationID, lastMessageID],
|
|
);
|
|
|
|
// Turn the list into a conversation messages list
|
|
ConversationMessagesList finalList = ConversationMessagesList();
|
|
finalList.addAll(list);
|
|
return finalList;
|
|
}
|
|
}
|