deleteMessage method

Future<void> deleteMessage({
  1. String? messageId,
  2. String? conversationId,
  3. required String channelName,
})

Implementation

Future<void> deleteMessage(
    {String? messageId,
    String? conversationId,
    required String channelName}) async {
  final request = messageId.toString();
  try {
    final response = channelName.toLowerCase() == 'twitter'
        ? await _conversationRepository.deleteTwitterMessage(request)
        : channelName.toLowerCase() == 'facebook'
            ? await _conversationRepository.deleteFacebookMessage(request)
            : channelName.toLowerCase() == 'instagram'
                ? await _conversationRepository
                    .deleteInstagramMessage(request)
                : const DeleteMessageResponse();

    if (response.status == 'success') {
      getSingleConversation(conversationId ?? '');
      // getAllConversations();
    }
  } catch (e) {
    if (e is DioError) {
      _loadingService.showError(
          e.response?.data['message'] ?? 'Unable to delete message');
    } else {
      _loadingService.showError('Unable to delete message');
    }
  }
}