<commit_before>import React from 'react';
import { buildURI } from 'lbryURI';
import FormField from 'component/formField';
import FileTile from 'component/fileTile';
import { BusyMessage } from 'component/common.js';

class FileList extends React.PureComponent {
  constructor(props) {
    super(props);

    this.state = {
      sortBy: 'dateNew',
    };

    this._sortFunctions = {
      dateNew: (fileInfos) =>
        fileInfos.slice().sort((fileInfo1, fileInfo2) => {
          const height1 = this.props.claimsById[fileInfo1.claim_id].height;
          const height2 = this.props.claimsById[fileInfo2.claim_id].height;
          if (height1 > height2) {
            return -1;
          } else if (height1 < height2) {
            return 1;
          }
          return 0;
        }),
      dateOld: (fileInfos) =>
        fileInfos.slice().sort((fileInfo1, fileInfo2) => {
          const height1 = this.props.claimsById[fileInfo1.claim_id].height;
          const height2 = this.props.claimsById[fileInfo2.claim_id].height;
          if (height1 < height2) {
            return -1;
          } else if (height1 > height2) {
            return 1;
          }
          return 0;
        }),
      title: (fileInfos) =>
        fileInfos.slice().sort((fileInfo1, fileInfo2) => {
          const title1 = fileInfo1.value
            ? fileInfo1.value.stream.metadata.title.toLowerCase()
            : fileInfo1.claim_name;
          const title2 = fileInfo2.value
            ? fileInfo2.value.stream.metadata.title.toLowerCase()
            : fileInfo2.claim_name;
          if (title1 < title2) {
            return -1;
          } else if (title1 > title2) {
            return 1;
          }
          return 0;
        }),
      filename: (fileInfos) =>
        fileInfos.slice().sort(({ file_name: fileName1 }, { file_name: fileName2 }) => {
          const fileName1Lower = fileName1.toLowerCase();
          const fileName2Lower = fileName2.toLowerCase();
          if (fileName1Lower < fileName2Lower) {
            return -1;
          } else if (fileName2Lower > fileName1Lower) {
            return 1;
          }
          return 0;
        }),
      };
    }

  getChannelSignature(fileInfo) {
    if (fileInfo.value) {
      return fileInfo.value.publisherSignature.certificateId;
    }
    return fileInfo.channel_claim_id;
  }

  handleSortChanged(event) {
    this.setState({
      sortBy: event.target.value,
    });
  }

  render() {
    const { handleSortChanged, fetching, fileInfos } = this.props;
    const { sortBy } = this.state;
    const content = [];

    this._sortFunctions[sortBy](fileInfos).forEach(fileInfo => {
      const uriParams = {};

      if (fileInfo.channel_name) {
        uriParams.channelName = fileInfo.channel_name;
        uriParams.contentName = fileInfo.claim_name;
        uriParams.claimId = this.getChannelSignature(fileInfo);
      } else {
        uriParams.claimId = fileInfo.claim_id;
        uriParams.claimName = fileInfo.claim_name || fileInfo.name;
      }<commit_msg>Remove channels from published page<commit_after>import React from 'react';
import { buildURI } from 'lbryURI';
import FormField from 'component/formField';
import FileTile from 'component/fileTile';
import { BusyMessage } from 'component/common.js';

class FileList extends React.PureComponent {
  constructor(props) {
    super(props);

    this.state = {
      sortBy: 'dateNew',
    };

    this._sortFunctions = {
      dateNew: (fileInfos) =>
        fileInfos.slice().sort((fileInfo1, fileInfo2) => {
          const height1 = this.props.claimsById[fileInfo1.claim_id].height;
          const height2 = this.props.claimsById[fileInfo2.claim_id].height;
          if (height1 > height2) {
            return -1;
          } else if (height1 < height2) {
            return 1;
          }
          return 0;
        }),
      dateOld: (fileInfos) =>
        fileInfos.slice().sort((fileInfo1, fileInfo2) => {
          const height1 = this.props.claimsById[fileInfo1.claim_id].height;
          const height2 = this.props.claimsById[fileInfo2.claim_id].height;
          if (height1 < height2) {
            return -1;
          } else if (height1 > height2) {
            return 1;
          }
          return 0;
        }),
      title: (fileInfos) =>
        fileInfos.slice().sort((fileInfo1, fileInfo2) => {
          const title1 = fileInfo1.value
            ? fileInfo1.value.stream.metadata.title.toLowerCase()
            : fileInfo1.claim_name;
          const title2 = fileInfo2.value
            ? fileInfo2.value.stream.metadata.title.toLowerCase()
            : fileInfo2.claim_name;
          if (title1 < title2) {
            return -1;
          } else if (title1 > title2) {
            return 1;
          }
          return 0;
        }),
      filename: (fileInfos) =>
        fileInfos.slice().sort(({ file_name: fileName1 }, { file_name: fileName2 }) => {
          const fileName1Lower = fileName1.toLowerCase();
          const fileName2Lower = fileName2.toLowerCase();
          if (fileName1Lower < fileName2Lower) {
            return -1;
          } else if (fileName2Lower > fileName1Lower) {
            return 1;
          }
          return 0;
        }),
      };
    }

  getChannelSignature(fileInfo) {
    if (fileInfo.value) {
      return fileInfo.value.publisherSignature.certificateId;
    }
    return fileInfo.channel_claim_id;
  }

  handleSortChanged(event) {
    this.setState({
      sortBy: event.target.value,
    });
  }

  render() {
    const { handleSortChanged, fetching, fileInfos } = this.props;
    const { sortBy } = this.state;
    const content = [];

    this._sortFunctions[sortBy](fileInfos).forEach(fileInfo => {
      const uriParams = {};

      if (fileInfo.channel_name) {
        uriParams.channelName = fileInfo.channel_name;
        uriParams.contentName = fileInfo.claim_name || fileInfo.name;
        uriParams.claimId = this.getChannelSignature(fileInfo);
      } else {
        uriParams.claimId = fileInfo.claim_id;
        uriParams.claimName = fileInfo.claim_name || fileInfo.name;
      }
{'fraction_non_alphanumeric': 0.11467364632749877, 'fraction_numerical': 0.018321609684279403, 'mean_word_length': 2.119387755102041, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 29, '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': '7646842', 'n_tokens_mistral': 1830, 'n_tokens_neox': 1828, 'n_words': 341}