createMemberMedium static method

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

Implementation

static Future<void> createMemberMedium(
    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 memberMedium = repository.fromMap(theNewItem);
    if (memberMedium != null) {
      var memberMediumAccessibleByGroup = toMemberMediumAccessibleByGroup(
          memberMedium.accessibleByGroup ??
              MemberMediumAccessibleByGroup.me.index);
      var helper = MemberMediumHelper(
          app, memberId, memberMediumAccessibleByGroup,
          accessibleByMembers: memberMedium.accessibleByMembers);
      var base = memberMedium.base;
      if (base == oldDocumentId) {
        base = newDocumentId;
      }
      await upload(
          repository,
          helper,
          base,
          memberMedium.ext,
          memberMedium.mediumType ?? 0,
          theNewItem,
          memberMedium.relatedMediumId);
    }
  } catch (e) {
    print("Error whilst creating public medium $e");
  }
}