<commit_before>import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { Query } from 'react-apollo';

import channelContextQuery from 'react/components/ModalBlockLightboxWithChannelContext/queries/channelContext';

import Modal from 'react/components/UI/Modal/Portal';
import LoadingIndicator from 'react/components/UI/LoadingIndicator';
import ModalFullscreenDialog from 'react/components/UI/ModalFullscreenDialog';
import ModalBlockLightbox from 'react/components/ModalBlockLightbox';

export default class ModalBlockLightboxWithChannelContext extends PureComponent {
  static propTypes = {
    id: PropTypes.number.isRequired,
    channel_id: PropTypes.number.isRequired,
  }

  state = {
    mode: 'open',
  }

  close = () =>
    this.setState({ mode: 'closed' });

  render() {
    const { id, channel_id } = this.props;
    const { mode } = this.state;

    if (mode !== 'open') return null;

    return (
      <Modal onClose={this.close} Dialog={ModalFullscreenDialog}>
        <Query query={channelContextQuery} variables={{ id: channel_id }}>
          {({ data, loading, error }) => {
            if (error) {
              console.error(error);
              return null;
            }

            if (loading) return <LoadingIndicator />;

            const ids = data.channel.skeleton.map(k => k.id);

            return (
              <ModalBlockLightbox
                id={id}
                ids={ids}
                onClose={this.close}
              />
            );
          }}
        </Query>
      </Modal>
    );
  }
}<commit_msg>Ensures we open the lightbox regardless of the contextual error<commit_after>import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { Query } from 'react-apollo';

import channelContextQuery from 'react/components/ModalBlockLightboxWithChannelContext/queries/channelContext';

import Modal from 'react/components/UI/Modal/Portal';
import LoadingIndicator from 'react/components/UI/LoadingIndicator';
import ModalFullscreenDialog from 'react/components/UI/ModalFullscreenDialog';
import ModalBlockLightbox from 'react/components/ModalBlockLightbox';

export default class ModalBlockLightboxWithChannelContext extends PureComponent {
  static propTypes = {
    id: PropTypes.number.isRequired,
    channel_id: PropTypes.number.isRequired,
  }

  state = {
    mode: 'open',
  }

  close = () =>
    this.setState({ mode: 'closed' });

  render() {
    const { id, channel_id } = this.props;
    const { mode } = this.state;

    if (mode !== 'open') return null;

    return (
      <Modal onClose={this.close} Dialog={ModalFullscreenDialog}>
        <Query query={channelContextQuery} variables={{ id: channel_id }}>
          {({ data, loading, error }) => {
            if (loading) return <LoadingIndicator />;

            let ids = [];

            if (error) {
              // Log the error but attempt to open the lightbox anyway
              console.error(error);
            }

            ids = data && data.channel.skeleton.map(k => k.id);

            return (
              <ModalBlockLightbox
                id={id}
                ids={ids}
                onClose={this.close}
              />
            );
          }}
        </Query>
      </Modal>
    );
  }
}
{'fraction_non_alphanumeric': 0.11620887413220646, 'fraction_numerical': 0.0, 'mean_word_length': 2.4701570680628273, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 21, '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': '4263134', 'n_tokens_mistral': 921, 'n_tokens_neox': 905, 'n_words': 213}