submitReport method

Future<void> submitReport(
  1. String chatId,
  2. String messageId,
  3. String userId,
  4. String currentUserId,
)

Submits the report to the server.

Sends the report for the message and optionally reports/blocks the user based on the current state.

chatId is the ID of the chat. messageId is the ID of the message being reported. userId is the ID of the user who created the message. currentUserId is the ID of the current user (who is reporting).

After submission, resets the provider state and calls onUserBlocked if the user was blocked.

Implementation

Future<void> submitReport(String chatId, String messageId, String userId, String currentUserId) async {
  _loading = true;
  notifyListeners();
  try {
    await service.reportMessage(
      chatId: chatId,
      messageId: messageId,
      reasonId: selectedReason!.id,
    );
    if (_reportUser) {
      await service.reportUser(chatId: chatId, userId: userId);
    }
    if (_blockUser) {
      await service.blockUser(
        chatId: chatId,
        userId: currentUserId,
        blockedUserId: userId,
      );
      onUserBlocked();
    }
  } finally {
    _loading = false;
    notifyListeners();
    reset();
  }
}