discardLocalMessage static method

Future<void> discardLocalMessage(
  1. String localMessageId, {
  2. required dynamic onSuccess(
    1. String result
    )?,
  3. required dynamic onError(
    1. CometChatException excep
    )?,
})

Offline: delete a message that has not been sent (BEH-SEND-36).

Accepts a PENDING or FAILED message and removes it, durably and on the device only — the message, its copied media, the reply-count bump its parent received, and its place as the conversation's last-message preview. It will not be sent later. onSuccess fires with the id once the discard has resolved; no other callback fires (the message's send listener is released with no final outcome). onError fires with ERROR_OFFLINE_MESSAGE_IN_FLIGHT for a SENDING message, ERROR_OFFLINE_MESSAGE_NOT_FOUND for an id with no unsent message, ERROR_OFFLINE_DISABLED when offline is not running, and the SDK's generic error code when the store is momentarily unavailable.

Implementation

static Future<void> discardLocalMessage(
  String localMessageId, {
  required Function(String localMessageId)? onSuccess,
  required Function(CometChatException e)? onError,
}) => OfflineRuntime.instance.discardLocalMessage(
  localMessageId,
  onSuccess: onSuccess,
  onError: onError,
);