mattermost-mobile/app/components/post/post.js
Harrison Healey 4ecd3758e7 Render posts for the current channel (#153)
* 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
2016-12-23 10:55:33 -03:00

45 lines
1.3 KiB
JavaScript

// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import React from 'react';
import {Text, View} from 'react-native';
import FormattedText from 'app/components/formatted_text';
import FormattedTime from 'app/components/formatted_time';
import {isSystemMessage} from 'service/utils/post_utils.js';
export default class Post extends React.Component {
static propTypes = {
post: React.PropTypes.object.isRequired,
user: React.PropTypes.object,
theme: React.PropTypes.object.isRequired
};
render() {
let displayName;
if (isSystemMessage(this.props.post)) {
displayName = 'System'; // TODO this should be localized
} else if (this.props.user) {
displayName = this.props.user.username;
} else {
displayName = (
<FormattedText
id='channel_loader.someone'
defaultMessage='Someone'
/>
);
}
return (
<View>
<Text>
{'['}
<FormattedTime value={this.props.post.create_at}/>
{'] '}
{displayName}
{': ' + this.props.post.message}</Text>
</View>
);
}
}