readChat method

Future<void> readChat(
  1. ChatItem? item
)

Marks the chat as read for the authenticated MyUser until the item inclusively.

Implementation

Future<void> readChat(ChatItem? item) async {
  if (active.isTrue &&
      item != null &&
      !chat!.chat.value.isReadBy(item, me) &&
      status.value.isSuccess &&
      !status.value.isLoadingMore &&
      item.status.value == SendingStatus.sent &&
      router.obscuring.isEmpty) {
    try {
      await _chatService.readChat(chat!.chat.value.id, item.id);
    } on ReadChatException catch (e) {
      MessagePopup.error(e);
    } on ConnectionException {
      // No-op.
    } catch (e) {
      MessagePopup.error(e);
      rethrow;
    }
  }
}