refreshRelations static method

Future<AssignmentModel> refreshRelations(
  1. AssignmentModel model
)

Implementation

static Future<AssignmentModel> refreshRelations(AssignmentModel model) async {
  WorkflowModel? workflowHolder;
  if (model.workflow != null) {
    try {
      await workflowRepository(appId: model.appId)!
          .get(model.workflow!.documentID)
          .then((val) {
        workflowHolder = val;
      }).catchError((error) {});
    } catch (_) {}
  }

  List<AssignmentResultModel>? resultsCurrentHolder;
  if (model.resultsCurrent != null) {
    resultsCurrentHolder = List<AssignmentResultModel>.from(
            await Future.wait(model.resultsCurrent!.map((element) async {
      return await AssignmentResultCache.refreshRelations(element);
    })))
        .toList();
  }

  List<AssignmentResultModel>? resultsPreviousHolder;
  if (model.resultsPrevious != null) {
    resultsPreviousHolder = List<AssignmentResultModel>.from(
            await Future.wait(model.resultsPrevious!.map((element) async {
      return await AssignmentResultCache.refreshRelations(element);
    })))
        .toList();
  }

  return model.copyWith(
    workflow: workflowHolder,
    resultsCurrent: resultsCurrentHolder,
    resultsPrevious: resultsPreviousHolder,
  );
}