getMutedConversations static method
Future<List<MutedConversation> >
getMutedConversations({
- dynamic onSuccess(
- List<
MutedConversation> mutedConversations
- List<
- dynamic onError()?,
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 sdk = SdkRegistry.getInstance();
final response = await sdk.notificationsApi.getMutedConversations();
final data = response['data'] as Map<String, dynamic>;
final mutedConversationsJson = data['mutedConversations'] as List? ?? [];
for (final item in mutedConversationsJson) {
mutedConversations
.add(MutedConversation.fromMap(item as Map<String, dynamic>));
}
if (onSuccess != null) onSuccess(mutedConversations);
return mutedConversations;
} catch (e) {
_handleError(e, onError);
}
return mutedConversations;
}