/* @flow */
import React, { PureComponent } from 'react';

import connectWithActions from '../connectWithActions';
import {
  isHomeNarrow,
  isPrivateNarrow,
  isGroupNarrow,
  isSpecialNarrow,
  isStreamNarrow,
  isTopicNarrow,
} from '../utils/narrow';
import { getSession } from '../selectors';

import type { Message, Narrow } from '../types';
import TitleHome from './TitleHome';
import TitlePrivate from './TitlePrivate';
import TitleGroup from './TitleGroup';
import TitleSpecial from './TitleSpecial';
import TitleStream from './TitleStream';
import TitlePlain from './TitlePlain';

const titles = [
  { isFunc: isHomeNarrow, component: TitleHome },
  { isFunc: isSpecialNarrow, component: TitleSpecial },
  { isFunc: isStreamNarrow, component: TitleStream },
  { isFunc: isTopicNarrow, component: TitleStream },
  { isFunc: isPrivateNarrow, component: TitlePrivate },
  { isFunc: isGroupNarrow, component: TitleGroup },
];

type Props = {
  narrow: Narrow,
  editMessage: Message,
  color: string,
};

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

  render() {
    const { narrow, editMessage, color } = this.props;

    if (editMessage != null) {
      return <TitlePlain text="Edit message" color={color} />;
    }

    const titleType = narrow && titles.find(x => x.isFunc(narrow));

    if (!titleType) {
      return null;
    }

    return <titleType.component color={color} narrow={narrow} />;
  }
}

export default connectWithActions(state => ({
  editMessage: getSession(state).editMessage,
}))(Title);

@@ -16,29 +16,16 @@
 ort 
-React, %7B PureComponen
+%7B connec
 t %7D 
@@ -35,16 +35,22 @@
 m 'react
+-redux
 ';%0A%0Aimpo
@@ -56,57 +56,48 @@
 ort 
-connectWithActions from '../connectWithActions
+React, %7B PureComponent %7D from 'react
 ';%0A
+%0A
 impo
@@ -1435,19 +1435,8 @@
 nect
-WithActions
 (sta

Use standard Redux Dispatch.