mediumCollectReferences function

Future<List<ModelReference>> mediumCollectReferences({
  1. String? appId,
  2. required String? relatedMediumId,
  3. required RepositoryBase repo,
  4. required String packageName,
  5. required String id,
})

Implementation

Future<List<ModelReference>> mediumCollectReferences(
    {String? appId,
    required String? relatedMediumId,
    required RepositoryBase repo,
    required String packageName,
    required String id}) async {
  List<ModelReference> referencesCollector = [];
  var searchThisId = relatedMediumId;
  while (searchThisId != null) {
    var newRelated = await repo.get(searchThisId);
    if (newRelated != null) {
      referencesCollector.add(ModelReference(packageName, id, newRelated));
      searchThisId = newRelated.relatedMediumId;
    } else {
      break;
    }
  }
  return referencesCollector;
}