<commit_before>// @flow

import type { ChatMessageInfoItemWithHeight } from './message.react';

import * as React from 'react';
import { View, Text, StyleSheet } from 'react-native';

import { stringForUser } from 'lib/shared/user-utils';

import Timestamp from './timestamp.react';

type Props = {|
  item: ChatMessageInfoItemWithHeight,
  focused: bool,
  color: 'light' | 'dark',
|};
function MessageHeader(props: Props) {
  const { item, focused, color } = props;
  const { creator, time } = item.messageInfo;
  const { isViewer } = creator;

  let authorName = null;
  if (!isViewer && (item.startsCluster || focused)) {
    const style = color === 'light'
      ? [ styles.authorName, styles.light ]
      : [ styles.authorName, styles.dark ];
    authorName = (
      <Text style={style} numberOfLines={1}>
        {stringForUser(creator)}
      </Text>
    );
  }

  const timestamp = focused || item.startsConversation
    ? <Timestamp time={time} color={color} />
    : null;
  if (!timestamp && !authorName) {
    return null;
  }

  const style = !item.startsCluster
    ? styles.clusterMargin
    : null;
  return (<commit_msg>[native] Don't show dark MessageHeader just because focused<commit_after>// @flow

import type { ChatMessageInfoItemWithHeight } from './message.react';

import * as React from 'react';
import { View, Text, StyleSheet } from 'react-native';

import { stringForUser } from 'lib/shared/user-utils';

import Timestamp from './timestamp.react';

type Props = {|
  item: ChatMessageInfoItemWithHeight,
  focused: bool,
  color: 'light' | 'dark',
|};
function MessageHeader(props: Props) {
  const { item, focused, color } = props;
  const { creator, time } = item.messageInfo;
  const { isViewer } = creator;

  let authorName = null;
  if (!isViewer && (item.startsCluster || focused)) {
    const style = color === 'light' || !item.startsCluster
      ? [ styles.authorName, styles.light ]
      : [ styles.authorName, styles.dark ];
    authorName = (
      <Text style={style} numberOfLines={1}>
        {stringForUser(creator)}
      </Text>
    );
  }

  const timestampColor = color === 'light' || !item.startsConversation
    ? 'light'
    : 'dark';
  const timestamp = focused || item.startsConversation
    ? <Timestamp time={time} color={timestampColor} />
    : null;
  if (!timestamp && !authorName) {
    return null;
  }

  const style = !item.startsCluster
    ? styles.clusterMargin
    : null;
  return (
{'fraction_non_alphanumeric': 0.14163614163614163, 'fraction_numerical': 0.000814000814000814, 'mean_word_length': 3.420863309352518, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '911635', 'n_tokens_mistral': 764, 'n_tokens_neox': 756, 'n_words': 195}