getMutedConversations static method

Future<List<MutedConversation>> getMutedConversations({
  1. dynamic onSuccess(
    1. List<MutedConversation> mutedConversations
    )?,
  2. dynamic onError(
    1. CometChatException e
    )?,
})

Retrieves a list of conversations that have been muted by the logged-in user.

This method makes an asynchronous call to the CometChat server to fetch all muted conversations. Upon successful retrieval, onSuccess is invoked with a list of MutedConversation objects. If an error occurs, onError is called with a CometChatException.

Returns a Future<List<MutedConversation>> which completes with the list of muted conversations, or an empty list if an error occurs.

Implementation

static Future<List<MutedConversation>> getMutedConversations(
    {Function(List<MutedConversation> mutedConversations)? onSuccess,
    Function(CometChatException e)? onError}) async {
  List<MutedConversation> mutedConversations = [];
  try {
    final result = await channel.invokeMethod('getMutedConversations');
    Map<dynamic, dynamic> map = result;
    map.forEach((key, value) {
      mutedConversations.add(MutedConversation.fromMap(value));
    });
    if (onSuccess != null) onSuccess(mutedConversations);
    return mutedConversations;
  } on PlatformException catch (p) {
    _errorCallbackHandler(null, p, null, onError);
  } catch (e) {
    _errorCallbackHandler(null, null, e, onError);
  }
  return mutedConversations;
}