<commit_before>/* @flow */
import React, { PureComponent } from 'react';
import { connect } from 'react-redux';

import type { Dispatch } from '../types';
import { updateExistingStream, navigateBack } from '../actions';
import { getStreamIdFromParams, getStreamFromParams } from '../selectors';
import { Screen } from '../common';
import EditStreamCard from './EditStreamCard';

type Props = {
  dispatch: Dispatch,
  initialValues: {
    name: string,
    description: string,
    invite_only: boolean,
  },
  streamId: number,
};

class EditStreamScreen extends PureComponent<Props> {
  props: Props;

  handleComplete = (name: string, description: string, isPrivate: boolean) => {
    const { dispatch, streamId, initialValues } = this.props;

    dispatch(updateExistingStream(streamId, initialValues, { name, description, isPrivate }));
    dispatch(navigateBack());
  };

  render() {
    const { initialValues } = this.props;

    return (
      <Screen title="Edit stream" padding>
        <EditStreamCard
          isNewStream={false}
          initialValues={initialValues}
          onComplete={this.handleComplete}
        />
      </Screen>
    );
  }
}

export default connect(state => ({
  initialValues: getStreamFromParams(state),
  streamId: getStreamIdFromParams(state).streamId,
}))(EditStreamScreen);<commit_msg>EditStreamScreen: Refactor to use simpler props.<commit_after>/* @flow */
import React, { PureComponent } from 'react';
import { connect } from 'react-redux';

import type { Dispatch, Stream } from '../types';
import { updateExistingStream, navigateBack } from '../actions';
import { getStreamFromParams } from '../selectors';
import { Screen } from '../common';
import EditStreamCard from './EditStreamCard';

type Props = {
  dispatch: Dispatch,
  stream: Stream,
};

class EditStreamScreen extends PureComponent<Props> {
  props: Props;

  handleComplete = (name: string, description: string, isPrivate: boolean) => {
    const { dispatch, stream } = this.props;

    dispatch(updateExistingStream(stream.stream_id, stream, { name, description, isPrivate }));
    dispatch(navigateBack());
  };

  render() {
    const { stream } = this.props;

    return (
      <Screen title="Edit stream" padding>
        <EditStreamCard
          isNewStream={false}
          initialValues={stream}
          onComplete={this.handleComplete}
        />
      </Screen>
    );
  }
}

export default connect(state => ({
  stream: getStreamFromParams(state),
}))(EditStreamScreen);
{'fraction_non_alphanumeric': 0.13224131042748702, 'fraction_numerical': 0.0, 'mean_word_length': 3.6979362101313322, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, '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': '2991416', 'n_tokens_mistral': 707, 'n_tokens_neox': 697, 'n_words': 180}