deleteSubscription method

Future<CtrlMessage> deleteSubscription(
  1. String userId
)

Delete subscription. Requires Share permission. Wrapper for Tinode.deleteSubscription

Implementation

Future<CtrlMessage> deleteSubscription(String userId) async {
  if (!isSubscribed) {
    return Future.error(
        Exception('Cannot delete subscription in inactive topic'));
  }
  // Send {del} message, return promise
  var ctrl = await _tinodeService.deleteSubscription(name ?? '', userId);
  // Remove the object from the subscription cache;
  _users.remove(userId);
  // Notify listeners
  onSubsUpdated.add(_users.values.toList());
  return CtrlMessage.fromMessage((ctrl));
}