createPublicMedium static method

Future<void> createPublicMedium(
  1. Map theNewItem,
  2. AppModel app,
  3. String memberId,
  4. RepositoryBase repository, {
  5. Map<String, String>? newDocumentIds,
})

Implementation

static Future<void> createPublicMedium(
    Map theNewItem, AppModel app, String memberId, RepositoryBase repository,
    {Map<String, String>? newDocumentIds}) async {
  var oldDocumentId = theNewItem["documentID"];
  renameDoc(theNewItem, newDocumentIds);
  var newDocumentId = theNewItem["documentID"];
  try {
    var publicMedium = repository.fromMap(theNewItem);
    if (publicMedium != null) {
      var helper = PublicMediumHelper(
        app,
        memberId,
      );
      var base = publicMedium.base;
      if (base == oldDocumentId) {
        base = newDocumentId;
      }
      await upload(
          repository,
          helper,
          base,
          publicMedium.ext,
          publicMedium.mediumType ?? 0,
          theNewItem,
          publicMedium.relatedMediumId);
    }
  } catch (e) {
    print("Error whilst creating public medium $e");
  }
}