chinwagsocial/app/assets/javascripts/components/features/community_timeline/index.jsx
Koala Yeung faefd8ec8f Update javascript English translation files and some defaultValue (#1676)
* Reorder javascript English locale file

 * Reorder translation string in order of the locale key.

* Add javascript English locale missing language keys

 * Search all javascript language keys by command:
   `grep -REho '<FormattedMessage .*\/>' ./app/assets/javascripts/.`

 * Add all the missing language keys and their values to `en.jsx`.

* Add javascript English locale missing language keys (2)

* Find all `defineMessages` calls with this command:
  `grep -Rl 'defineMessages({.*' ./app/assets/javascripts/.`

* Open all these files. Find the language key (`id`) in these
  statements.

* Add all the missing language keys and their values to `en.jsx`.

* Remove javascript English locale obsoleted language keys

 * Find all language keys that no longer exists in the source code
  and remove them. The removed keys include:

    * "compose_form.private"
    * "compose_form.unlisted"
    * "getting_started.about_addressing"
    * "getting_started.about_shortcuts"
    * "notification.mention"
    * "search.account"
    * "search.hashtag"
    * "tabs_bar.mentions"
    * "tabs_bar.public"

* Javascript English locale file add note

 * Add notes to contributors about the English translation files.
   Hope that will make translation process smoother.

* Update javascript locale defaultValue in code

 * Update the defaultValue in code according to the relevant
   translation in English locale file.
2017-04-13 12:57:41 +02:00

96 lines
2.5 KiB
JavaScript

import { connect } from 'react-redux';
import PureRenderMixin from 'react-addons-pure-render-mixin';
import StatusListContainer from '../ui/containers/status_list_container';
import Column from '../ui/components/column';
import {
refreshTimeline,
updateTimeline,
deleteFromTimelines,
connectTimeline,
disconnectTimeline
} from '../../actions/timelines';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
import ColumnBackButtonSlim from '../../components/column_back_button_slim';
import createStream from '../../stream';
const messages = defineMessages({
title: { id: 'column.community', defaultMessage: 'Local timeline' }
});
const mapStateToProps = state => ({
hasUnread: state.getIn(['timelines', 'community', 'unread']) > 0,
accessToken: state.getIn(['meta', 'access_token'])
});
let subscription;
const CommunityTimeline = React.createClass({
propTypes: {
dispatch: React.PropTypes.func.isRequired,
intl: React.PropTypes.object.isRequired,
accessToken: React.PropTypes.string.isRequired,
hasUnread: React.PropTypes.bool
},
mixins: [PureRenderMixin],
componentDidMount () {
const { dispatch, accessToken } = this.props;
dispatch(refreshTimeline('community'));
if (typeof subscription !== 'undefined') {
return;
}
subscription = createStream(accessToken, 'public:local', {
connected () {
dispatch(connectTimeline('community'));
},
reconnected () {
dispatch(connectTimeline('community'));
},
disconnected () {
dispatch(disconnectTimeline('community'));
},
received (data) {
switch(data.event) {
case 'update':
dispatch(updateTimeline('community', JSON.parse(data.payload)));
break;
case 'delete':
dispatch(deleteFromTimelines(data.payload));
break;
}
}
});
},
componentWillUnmount () {
// if (typeof subscription !== 'undefined') {
// subscription.close();
// subscription = null;
// }
},
render () {
const { intl, hasUnread } = this.props;
return (
<Column icon='users' active={hasUnread} heading={intl.formatMessage(messages.title)}>
<ColumnBackButtonSlim />
<StatusListContainer type='community' emptyMessage={<FormattedMessage id='empty_column.community' defaultMessage='The local timeline is empty. Write something publicly to get the ball rolling!' />} />
</Column>
);
},
});
export default connect(mapStateToProps)(injectIntl(CommunityTimeline));