unlinkChildRoom function

Future<void> unlinkChildRoom(
  1. dynamic context,
  2. dynamic ref, {
  3. required String parentId,
  4. required String roomId,
  5. String? reason,
})

Implementation

Future<void> unlinkChildRoom(
  BuildContext context,
  WidgetRef ref, {
  required String parentId,
  required String roomId,
  String? reason,
}) async {
  reason = reason ?? L10n.of(context).unlinkRoom;
  //Fetch selected parent space data and add given roomId as child
  final space = await ref.read(spaceProvider(parentId).future);
  if (!context.mounted) return;
  await space.removeChildRoom(roomId, reason);
  //Fetch selected room data and add given parentSpaceId as parent
  final room = await ref.read(maybeRoomProvider(roomId).future);
  if (room != null && room.isSpace()) {
    await room.removeParentRoom(parentId, reason);
  }
  // spaceRelations come from the server and must be manually invalidated
  ref.invalidate(spaceRelationsProvider(parentId));
  ref.invalidate(spaceRemoteRelationsProvider(parentId));
}