<commit_before>import React from 'react';
import { loadImage } from '../../../../shared/utils/network';
import { getTimeOffset } from '../../../../shared/utils/time';
import { Card, CardHeader } from '../../../../shared/components/Card';

import {
  Title, Icon, Source, SecondaryText, CardImage, Overline, SourceContainer,
} from './styles';

export interface Props {
  data: any;
}

export interface State {
  loaded: boolean;
}

export default class NewsCard extends React.Component<Props, State> {
  public state: State = {
    loaded: false,
  };

  public async componentDidMount() {
    const { data } = this.props;

    await loadImage(data.urlToImage);
    await loadImage(data.icon);

    this.setState({ loaded: true });
  }

  public render() {
    const { data } = this.props;
    const { loaded } = this.state;

    const desc = data.description.replace(/&nbsp;/g, '');

    return (
      <a href={data.url}>
        <Card>
          <CardImage visible={loaded} src={data.urlToImage} />
          <CardHeader>
            <Overline>{getTimeOffset(new Date(data.publishedAt), this)}</Overline>
            <Title>{data.title}</Title>

            {data.description
              && data.description.indexOf('�') === -1
              && desc.trim() !== '' && <SecondaryText>{desc}</SecondaryText>}

            <SourceContainer>
              <Icon visible={loaded} source={data.icon} />
              <Source>{data.source.name}</Source>
            </SourceContainer>
          </CardHeader>
        </Card>
      </a>
    );
  }
}<commit_msg>:ambulance: Fix critical error with newtab news cards<commit_after>import React from 'react';
import { loadImage } from '../../../../shared/utils/network';
import { getTimeOffset } from '../../../../shared/utils/time';
import { Card, CardHeader } from '../../../../shared/components/Card';

import {
  Title, Icon, Source, SecondaryText, CardImage, Overline, SourceContainer,
} from './styles';

export interface Props {
  data: any;
}

export interface State {
  loaded: boolean;
}

export default class NewsCard extends React.Component<Props, State> {
  public state: State = {
    loaded: false,
  };

  public async componentDidMount() {
    const { data } = this.props;

    await loadImage(data.urlToImage);
    await loadImage(data.icon);

    this.setState({ loaded: true });
  }

  public render() {
    const { data } = this.props;
    const { loaded } = this.state;

    let desc: string = data.description;
    if (data && data.description) {
      desc = data.description.replace(/&nbsp;/g, '');
    }

    return (
      <a href={data.url}>
        <Card>
          <CardImage visible={loaded} src={data.urlToImage} />
          <CardHeader>
            <Overline>{getTimeOffset(new Date(data.publishedAt), this)}</Overline>
            <Title>{data.title}</Title>

            {desc
              && desc.indexOf('�') === -1
              && desc.trim() !== '' && <SecondaryText>{desc}</SecondaryText>}

            <SourceContainer>
              <Icon visible={loaded} source={data.icon} />
              <Source>{data.source.name}</Source>
            </SourceContainer>
          </CardHeader>
        </Card>
      </a>
    );
  }
}
{'fraction_non_alphanumeric': 0.16671860392645685, 'fraction_numerical': 0.0006232471174820816, 'mean_word_length': 2.3577405857740588, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, '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': '6336514', 'n_tokens_mistral': 930, 'n_tokens_neox': 917, 'n_words': 211}