markAsRead method

Future<VIConversationServiceEvent> markAsRead(
  1. int sequence
)

Mark the event with the specified sequence as read.

A method call with the specified sequence makes the VIConversationParticipant.lastReadSequence property return this sequence, i.e., such sequences can be get for each participant separately.

If the sequence parameter specified less than 1, the method will mark all the events as unread (for this participant) except the event with the sequence equals to '1'.

Other parties of the conversation (online participants and logged in clients) can be informed about marking events as read via the VIMessenger.onRead callback.

sequence - Sequence number of the event in the conversation to be marked as read. Shouldn't be greater than currently possible.

Throws VIException, if operation failed, otherwise returns VIConversationServiceEvent instance. For all possible errors see VIMessagingError

Implementation

Future<VIConversationServiceEvent> markAsRead(int sequence) async {
  try {
    Map<String, dynamic>? data = await _methodChannel.invokeMapMethod(
        'Messaging.markAsRead', {'conversation': uuid, 'sequence': sequence});
    if (data == null) {
      _VILog._e('VIConversation: markAsRead: data was null, skipping');
      throw VIException(
        VIMessagingError.ERROR_INTERNAL,
        'VIConversation:markAsRead: data was null',
      );
    }
    return VIConversationServiceEvent._fromMap(data);
  } on PlatformException catch (e) {
    throw VIException(e.code, e.message);
  }
}