fetchPrevious method

Future<List<Reaction>> fetchPrevious({
  1. required dynamic onSuccess(
    1. List<Reaction> message
    )?,
  2. required dynamic onError(
    1. CometChatException excep
    )?,
})

Asynchronously fetches the previous set of reactions for a specific message.

This method invokes the 'fetchNextMessageRequest' method on the platform-specific implementation, with 'limit', 'messageId', and 'reaction' passed as parameters. The 'limit' parameter defines the max number of message reactions to be fetched. The 'messageId' specifies the ID of the message for which the reactions are fetched. The 'reaction' parameter specifies the reaction to be used for filtering.

If successful, this function will convert the result into a list of MessageReaction objects and will call the onSuccess callback with this list. If an exception is thrown during the fetch operation or during the conversion of the result, onError callback will be invoked with a CometChatException.

@param onSuccess A callback function to be invoked upon the successful fetching of previous reactions. This function receives a list of fetched MessageReaction objects as a parameter. @param onError A callback function to be invoked when an exception is thrown during the fetch operation or the conversion of the result. This function will receive a CometChatException that details the error. @return A Future that completes with a list of MessageReaction objects. If an error is encountered, the future completes with an empty list.

Implementation

Future<List<Reaction>> fetchPrevious(
    {required Function(List<Reaction> message)? onSuccess,
    required Function(CometChatException excep)? onError}) async {
  return await _fetchNextAndPreviousForReactionsRequest(1,
      onSuccess: onSuccess, onError: onError);
}