resolveWith method

Message resolveWith(
  1. Map changes
)

Implementation

Message resolveWith(Map changes) {
  final keys = MessageKeys.i;

  final id = changes[keys.id];
  final roomId = changes[keys.roomId];
  final senderId = changes[keys.senderId];
  final type = changes[keys.type];
  final statuses = changes[keys.statuses];
  final createdAt = changes[keys.createdAt];
  final updatedAt = changes[keys.updatedAt];
  final replyId = changes[keys.replyId];
  final reactions = changes[keys.reactions];
  final pins = changes[keys.pins];
  final deletes = changes[keys.deletes];
  final removes = changes[keys.removes];
  final isDeleted = changes[keys.isDeleted];
  final isEdited = changes[keys.isEdited];
  final editedAt = changes[keys.editedAt];
  final isForwarded = changes[keys.isForwarded];
  final extra = changes[keys.extra];

  return Message(
    id: id is String && id.isNotEmpty ? id : this.id,
    roomId: roomId is String && roomId.isNotEmpty ? roomId : this.roomId,
    senderId:
        senderId is String && senderId.isNotEmpty ? senderId : this.senderId,
    type: MessageType.values.tryParse(type) ?? this.type,
    statuses: MessageStatus.values.tryReferences(statuses) ?? this.statuses,
    createdAt: ChatValueTimestamp.tryParse(createdAt) ?? this.createdAt,
    updatedAt: ChatValueTimestamp.tryParse(updatedAt) ?? this.updatedAt,
    editedAt: ChatValueTimestamp.tryParse(editedAt) ?? this.editedAt,
    reactions:
        reactions is Map
            ? reactions.tryParse() ?? this.reactions
            : this.reactions,
    deletes:
        deletes is Map ? deletes.tryParse() ?? this.deletes : this.deletes,
    pins: pins is Map ? pins.tryParse() ?? this.pins : this.pins,
    removes:
        removes is Map ? removes.tryParse() ?? this.removes : this.removes,
    replyId: replyId is String && replyId.isNotEmpty ? replyId : this.replyId,
    isEdited: isEdited is bool ? isEdited : this.isEdited,
    isForwarded: isForwarded is bool ? isForwarded : this.isForwarded,
    isDeleted: isDeleted is bool ? isDeleted : this.isDeleted,
    extra: extra is Map ? extra.tryParse() ?? this.extra : this.extra,
  );
}