mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-07-03 15:13:29 +00:00
Do not retrieve twice the same message
This commit is contained in:
@ -10,6 +10,7 @@ import 'package:comunic/models/conversation.dart';
|
||||
import 'package:comunic/models/conversation_message.dart';
|
||||
import 'package:comunic/models/new_conversation_message.dart';
|
||||
import 'package:comunic/utils/account_utils.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
/// Conversation helper
|
||||
///
|
||||
@ -137,7 +138,8 @@ class ConversationsHelper {
|
||||
///
|
||||
/// Set [lastMessageID] to 0 to specify that we do not have any message of the
|
||||
/// conversation yet or another value else
|
||||
Future<ConversationMessagesList> downloadNewMessagesSingle(int conversationID,
|
||||
Future<ConversationMessagesList> _downloadNewMessagesSingle(
|
||||
int conversationID,
|
||||
{int lastMessageID = 0}) async {
|
||||
// Execute the request on the server
|
||||
final response = await APIRequest(
|
||||
@ -168,6 +170,17 @@ class ConversationsHelper {
|
||||
return list;
|
||||
}
|
||||
|
||||
/// Get new messages for a given conversation
|
||||
///
|
||||
/// If [lastMessageID] is set to 0 then we retrieve the last messages of
|
||||
/// the conversation.
|
||||
/// Otherwise [lastMessageID] contains the ID of the last known message
|
||||
Future<ConversationMessagesList> getNewMessages(
|
||||
{@required int conversationID, int lastMessageID = 0}) async {
|
||||
return await _downloadNewMessagesSingle(conversationID,
|
||||
lastMessageID: lastMessageID);
|
||||
}
|
||||
|
||||
/// Send a new message to the server
|
||||
Future<SendMessageResult> sendMessage(NewConversationMessage message) async {
|
||||
final request = APIRequest(
|
||||
|
Reference in New Issue
Block a user