File size: 1,197 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
// @flow
import React from 'react';
import compose from 'recompose/compose';
import type { UserInfoType } from 'shared/graphql/fragments/user/userInfo';
import type { GetThreadType } from 'shared/graphql/queries/thread/getThread';
import type { GetDirectMessageThreadType } from 'shared/graphql/queries/directMessageThread/getDirectMessageThread';
import type { MessageInfoType } from 'shared/graphql/fragments/message/messageInfo';
import { withCurrentUser } from 'src/components/withCurrentUser';
import ThreadMessages from './thread';
import DirectMessages from './directMessage';
type DirectMessageThreadProps = {
threadType: 'directMessageThread',
thread?: GetDirectMessageThreadType,
messages: Array<?MessageInfoType>,
currentUser: ?UserInfoType,
};
type StoryProps = {
threadType: 'story',
thread?: GetThreadType,
messages: Array<?MessageInfoType>,
currentUser: ?UserInfoType,
};
export type Props = DirectMessageThreadProps | StoryProps;
const ChatMessages = (props: Props) => {
if (props.threadType === 'story') return <ThreadMessages {...props} />;
// $FlowIssue
return <DirectMessages {...props} />;
};
export default compose(withCurrentUser)(ChatMessages);
|