* Added selectChannel action * Fixed selected team not being cleared on logout * Fixed posts and postsByChannel not being initialized correctly * Added basic post rendering * Renamed selectors files to be plural * Removed empty file * Fixed unit tests after merge * Removing unnecessary code
43 lines
1 KiB
JavaScript
43 lines
1 KiB
JavaScript
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
|
// See License.txt for license information.
|
|
|
|
import React from 'react';
|
|
import {ListView} from 'react-native';
|
|
|
|
import Post from 'app/components/post';
|
|
|
|
export default class PostList extends React.Component {
|
|
static propTypes = {
|
|
posts: React.PropTypes.arrayOf(React.PropTypes.object).isRequired
|
|
};
|
|
|
|
constructor(props) {
|
|
super(props);
|
|
|
|
this.state = {
|
|
dataSource: new ListView.DataSource({
|
|
rowHasChanged: (a, b) => a !== b
|
|
}).cloneWithRows(this.props.posts)
|
|
};
|
|
}
|
|
|
|
componentWillReceiveProps(nextProps) {
|
|
this.setState({
|
|
dataSource: this.state.dataSource.cloneWithRows(nextProps.posts)
|
|
});
|
|
}
|
|
|
|
renderPost(post) {
|
|
return <Post post={post}/>;
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<ListView
|
|
enableEmptySections={true}
|
|
dataSource={this.state.dataSource}
|
|
renderRow={this.renderPost}
|
|
/>
|
|
);
|
|
}
|
|
}
|