formatChatThreadStatusText function

String formatChatThreadStatusText(
  1. String text, {
  2. DateTime? startedAt,
  3. int? totalBytes,
  4. int? linesAdded,
  5. int? linesRemoved,
})

Implementation

String formatChatThreadStatusText(String text, {DateTime? startedAt, int? totalBytes, int? linesAdded, int? linesRemoved}) {
  if (linesAdded != null || linesRemoved != null) {
    final added = linesAdded != null ? "+${_formatGroupedStatusByteDigits(linesAdded)}" : null;
    final removed = linesRemoved != null ? "-${_formatGroupedStatusByteDigits(linesRemoved)}" : null;
    return [text, ?added, ?removed].join(" ");
  }
  if (totalBytes != null && totalBytes > 100) {
    return "$text ${_formatStatusByteCount(totalBytes)}";
  }
  if (startedAt == null) {
    return text;
  }

  final elapsed = DateTime.now().difference(startedAt);
  final seconds = _clampedElapsedSeconds(elapsed);
  if (seconds == 0) {
    return text;
  }
  return "$text ${_formatStatusSecondCount(seconds)}";
}