2016-04-29 03:02:51 +08:00
|
|
|
import React, { Component, PropTypes } from 'react';
|
|
|
|
import { createContainer } from 'meteor/react-meteor-data';
|
|
|
|
|
2016-05-23 21:09:47 +08:00
|
|
|
import Chat from './component';
|
2016-06-02 00:33:19 +08:00
|
|
|
import ChatService from './service';
|
|
|
|
|
|
|
|
const PUBLIC_CHAT_KEY = 'public';
|
2016-04-29 03:02:51 +08:00
|
|
|
|
|
|
|
class ChatContainer extends Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
2016-06-02 00:33:19 +08:00
|
|
|
<Chat {...this.props}>
|
2016-04-29 03:02:51 +08:00
|
|
|
{this.props.children}
|
|
|
|
</Chat>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-02 00:33:19 +08:00
|
|
|
export default createContainer(({ params }) => {
|
|
|
|
const chatID = params.chatID || PUBLIC_CHAT_KEY;
|
|
|
|
|
|
|
|
let messages = [];
|
|
|
|
|
|
|
|
if (chatID === PUBLIC_CHAT_KEY) {
|
|
|
|
title = 'Public Chat';
|
|
|
|
messages = ChatService.getPublicMessages();
|
|
|
|
} else {
|
|
|
|
title = 'Username';
|
|
|
|
messages = ChatService.getPrivateMessages(chatID);
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
title,
|
|
|
|
messages,
|
|
|
|
};
|
2016-04-29 03:02:51 +08:00
|
|
|
}, ChatContainer);
|