mattermost-mobile/app/components/root/root_container.js
2017-04-10 11:33:35 -03:00

53 lines
1.5 KiB
JavaScript

// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import Config from 'assets/config.json';
import {closeDrawers, closeModal, goBack, unrenderDrawer} from 'app/actions/navigation';
import {goToNotification, loadConfigAndLicense, queueNotification} from 'app/actions/views/root';
import {setAppState, setDeviceToken} from 'mattermost-redux/actions/general';
import {logout} from 'mattermost-redux/actions/users';
import Root from './root';
function mapStateToProps(state, ownProps) {
const users = state.entities.users;
const {currentUserId} = users;
const {currentTeamId} = state.entities.teams;
const {currentChannelId} = state.entities.channels;
let locale = Config.DefaultLocale;
if (currentUserId && users.profiles[currentUserId]) {
locale = users.profiles[currentUserId].locale;
}
return {
...ownProps,
currentTeamId,
currentChannelId,
locale,
navigation: state.navigation
};
}
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
closeDrawers,
closeModal,
goBack,
loadConfigAndLicense,
logout,
goToNotification,
queueNotification,
setAppState,
setDeviceToken,
unrenderDrawer
}, dispatch)
};
}
export default connect(mapStateToProps, mapDispatchToProps)(Root);