updateSpace function

Future<SpaceDTO?> updateSpace({
  1. String? account,
  2. Signer? signer,
  3. required String spaceId,
  4. required String spaceName,
  5. required String spaceDescription,
  6. String? spaceImage,
  7. required List<String> listeners,
  8. required List<String> speakers,
  9. String? pgpPrivateKey,
  10. String? meta,
  11. required DateTime scheduleAt,
  12. DateTime? scheduleEnd,
  13. required ChatStatus status,
})

Implementation

Future<SpaceDTO?> updateSpace({
  String? account,
  Signer? signer,
  required String spaceId,
  required String spaceName,
  required String spaceDescription,
  String? spaceImage,
  required List<String> listeners,
  required List<String> speakers,
  String? pgpPrivateKey,
  String? meta,
  required DateTime scheduleAt,
  DateTime? scheduleEnd,
  required ChatStatus status,
}) async {
  account ??= getCachedWallet()?.address;
  signer ??= getCachedWallet()?.signer;
  pgpPrivateKey ??= getCachedWallet()?.pgpPrivateKey;
  try {
    final space = await getSpaceById(spaceId: spaceId);

    if (space.status == ChatStatus.ACTIVE) {
      throw Exception('Unable change the start date/time of an active space');
    }

    if (space.status == ChatStatus.ENDED && scheduleEnd != null) {
      throw Exception('Unable change the end date/time of an ended space');
    }

    final group = await push.updateGroup(
        chatId: spaceId,
        groupName: spaceName,
        groupImage: spaceImage,
        groupDescription: spaceDescription,
        members: listeners,
        admins: speakers,
        signer: signer,
        pgpPrivateKey: pgpPrivateKey,
        scheduleAt: scheduleAt,
        scheduleEnd: scheduleEnd,
        status: status,
        isPublic: space.isPublic);

    if (group != null) {
      return groupDtoToSpaceDto(group);
    } else {
      throw Exception('Error while updating Space : $spaceId');
    }
  } catch (e) {
    print('[Push SDK] - API  - Error - API update -:  $e');
    rethrow;
  }
}