fromEntityPlus static method

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

Implementation

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

  var counter = 0;
  return ChatModel(
    documentID: documentID,
    authorId: entity.authorId ?? '',
    appId: entity.appId ?? '',
    roomId: entity.roomId,
    timestamp: entity.timestamp == null
        ? null
        : DateTime.fromMillisecondsSinceEpoch((entity.timestamp as int)),
    saying: entity.saying,
    accessibleByGroup: toChatAccessibleByGroup(entity.accessibleByGroup),
    accessibleByMembers: entity.accessibleByMembers,
    readAccess: entity.readAccess,
    chatMedia: entity.chatMedia == null
        ? null
        : List<ChatMediumModel>.from(
            await Future.wait(entity.chatMedia!.map((item) {
            counter++;
            return ChatMediumModel.fromEntityPlus(counter.toString(), item,
                appId: appId);
          }).toList())),
  );
}