getFactsForContact method

Future<Facts> getFactsForContact(
  1. MKey contactId
)

Implementation

Future<Facts> getFactsForContact(MKey contactId) async {
  await isLoaded;

  final result = await _factApi.factsByRecordKey(recordKey: contactId.value);
  final sanitized = result.data?.mapNotNull((fact) {
        final schema = _factSchemas["${fact.mtype}"];
        if (schema == null) {
          log.warning("Ignoring fact with missing type: ${fact.mtype}");
          return null;
        }
        fact.factSchema = schema;
        return fact;
      }) ??
      [];
  return Facts.of(count: sanitized.length, data: [...sanitized]);
}