PLT-6214 Move channel store and actions over to redux (#6235)

* Move channel store and actions over to redux

* Fix style errors

* Fix unit test

* Various fixes

* More fixes

* Revert config changes
Этот коммит содержится в:
Joram Wilander
2017-04-28 13:16:03 -04:00
коммит произвёл Christopher Speller
родитель 302ec17bee
Коммит 96906482ce
30 изменённых файлов: 499 добавлений и 691 удалений

24
webapp/components/post_view/index.js Обычный файл
Просмотреть файл

@@ -0,0 +1,24 @@
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {viewChannel} from 'mattermost-redux/actions/channels';
import PostViewCache from './post_view_cache.jsx';
function mapStateToProps(state, ownProps) {
return {
...ownProps
};
}
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
viewChannel
}, dispatch)
};
}
export default connect(mapStateToProps, mapDispatchToProps)(PostViewCache);

Просмотреть файл

@@ -5,13 +5,18 @@ import PostViewController from './post_view_controller.jsx';
import ChannelStore from 'stores/channel_store.jsx';
import UserStore from 'stores/user_store.jsx';
import * as AsyncClient from 'utils/async_client.jsx';
import React from 'react';
const MAXIMUM_CACHED_VIEWS = 5;
export default class PostViewCache extends React.Component {
static propTypes = {
actions: React.PropTypes.shape({
viewChannel: React.PropTypes.func.isRequired
}).isRequired
}
constructor(props) {
super(props);
@@ -32,7 +37,7 @@ export default class PostViewCache extends React.Component {
componentWillUnmount() {
if (UserStore.getCurrentUser()) {
AsyncClient.viewChannel('', this.state.currentChannelId || '');
this.props.actions.viewChannel('', this.state.currentChannelId || '');
}
ChannelStore.removeChangeListener(this.onChannelChange);
}