* Fixed copyright date * Removed unnecessary components folder from channel scene * Added initial version of post textbox * Moved getTheme into a proper selector * Moved ChannelHeader into its own component * Flipped post list so that the most recent posts appear at the bottom * Moved post textbox value into redux view store * Switched new components from PureRenderMixin to React.PureComponent
49 lines
1.2 KiB
JavaScript
49 lines
1.2 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
|
|
style={{transform: [{rotate: '180deg'}]}}
|
|
post={post}
|
|
/>
|
|
);
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<ListView
|
|
style={{transform: [{rotate: '180deg'}]}}
|
|
enableEmptySections={true}
|
|
dataSource={this.state.dataSource}
|
|
renderRow={this.renderPost}
|
|
/>
|
|
);
|
|
}
|
|
}
|