fromEntity static method
Implementation
static Future<ChatModel?> fromEntity(
String documentID, ChatEntity? entity) 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.fromEntity(counter.toString(), item);
}).toList())),
);
}