unsubscribeFromThread static method

Future<String?> unsubscribeFromThread(
  1. int parentMessageId, {
  2. dynamic onSuccess(
    1. String result
    )?,
  3. dynamic onError(
    1. CometChatException excep
    )?,
})

Unsubscribes the logged-in user from the thread rooted at parentMessageId.

Unfollowing is not sticky: replying to the thread again, or being @-mentioned in it, re-subscribes the user. The server also hard-deletes the thread's row from the participated-threads list, so a consumer holding a list from ThreadsRequest must remove the row locally. Unsubscribing when not subscribed succeeds (idempotent).

Implementation

static Future<String?> unsubscribeFromThread(int parentMessageId,
    {Function(String response)? onSuccess,
    Function(CometChatException e)? onError}) async {
  try {
    final sdk = SdkRegistry.getInstance();
    final result = await sdk.threads.unsubscribeFromThread(parentMessageId);
    if (onSuccess != null) onSuccess(result);
    return result;
  } on SdkException catch (sdkEx) {
    final cometChatEx = CometChatException(
      sdkEx.code,
      sdkEx.details ?? sdkEx.message,
      sdkEx.message,
    );
    _errorCallbackHandler(cometChatEx, null, null, onError);
  } catch (e) {
    _errorCallbackHandler(null, null, e, onError);
  }
  return null;
}