fromEntityPlus static method

Future<PostModel?> fromEntityPlus(
  1. String documentID,
  2. PostEntity? entity, {
  3. String? appId,
})

Implementation

static Future<PostModel?> fromEntityPlus(
    String documentID, PostEntity? entity,
    {String? appId}) async {
  if (entity == null) return null;

  var counter = 0;
  return PostModel(
    documentID: documentID,
    authorId: entity.authorId ?? '',
    timestamp: entity.timestamp == null
        ? null
        : DateTime.fromMillisecondsSinceEpoch((entity.timestamp as int)),
    appId: entity.appId ?? '',
    feedId: entity.feedId,
    postAppId: entity.postAppId,
    postPageId: entity.postPageId,
    pageParameters: entity.pageParameters,
    html: entity.html,
    description: entity.description,
    likes: entity.likes,
    dislikes: entity.dislikes,
    accessibleByGroup: toPostAccessibleByGroup(entity.accessibleByGroup),
    accessibleByMembers: entity.accessibleByMembers,
    readAccess: entity.readAccess,
    archived: toPostArchiveStatus(entity.archived),
    externalLink: entity.externalLink,
    memberMedia: entity.memberMedia == null
        ? null
        : List<MemberMediumContainerModel>.from(
            await Future.wait(entity.memberMedia!.map((item) {
            counter++;
            return MemberMediumContainerModel.fromEntityPlus(
                counter.toString(), item,
                appId: appId);
          }).toList())),
  );
}