mattermost-mobile/app/screens/channel/index.js
Harrison Healey 8c86a95f19 RN-349 Mark channel as read when switching teams and opening the app (#953)
* RN-349 Mark current channel as read when opening the app

* RN-349 Mark channels as read when switching teams

* Moved markChannelAsRead into handleTeamChange action
2017-10-02 16:03:13 -03:00

62 lines
2 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 {
loadChannelsIfNecessary,
loadProfilesAndTeamMembersForDMSidebar,
selectInitialChannel
} from 'app/actions/views/channel';
import {connection} from 'app/actions/device';
import {selectFirstAvailableTeam} from 'app/actions/views/select_team';
import {getStatusBarHeight} from 'app/selectors/device';
import {getTheme} from 'app/selectors/preferences';
import {viewChannel, markChannelAsRead} from 'mattermost-redux/actions/channels';
import {startPeriodicStatusUpdates, stopPeriodicStatusUpdates} from 'mattermost-redux/actions/users';
import {getCurrentChannelId} from 'mattermost-redux/selectors/entities/channels';
import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams';
import {
init as initWebSocket,
close as closeWebSocket
} from 'mattermost-redux/actions/websocket';
import Channel from './channel';
function mapStateToProps(state, ownProps) {
const {websocket} = state.requests.general;
const {myChannels: channelsRequest} = state.requests.channels;
return {
...ownProps,
currentTeamId: getCurrentTeamId(state),
currentChannelId: getCurrentChannelId(state),
theme: getTheme(state),
webSocketRequest: websocket,
statusBarHeight: getStatusBarHeight(state),
channelsRequestStatus: channelsRequest.status
};
}
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
connection,
loadChannelsIfNecessary,
loadProfilesAndTeamMembersForDMSidebar,
markChannelAsRead,
selectFirstAvailableTeam,
selectInitialChannel,
initWebSocket,
closeWebSocket,
startPeriodicStatusUpdates,
stopPeriodicStatusUpdates,
viewChannel
}, dispatch)
};
}
export default connect(mapStateToProps, mapDispatchToProps)(Channel);