mattermost-mobile/app/screens/user_profile/index.js
Daniel Espino García 4c8594d330
Add linter rules for import order and type member delimiters (#5514)
* Add linter rules for import order and type member delimiters

* Remove unneeded group

* Group all app/* imports before the internal imports

* Move app/ imports before parent imports

* Separate @node_modules imports into a different group

* Substitute app paths by aliases

* Fix @node_modules import order and add test related modules

* Add aliases for types and test, and group import types
2021-07-23 11:06:04 +02:00

64 lines
2.8 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {setChannelDisplayName} from '@actions/views/channel';
import {unsetCustomStatus} from '@actions/views/custom_status';
import {makeDirectChannel} from '@actions/views/more_dms';
import {loadBot} from '@mm-redux/actions/bots';
import {getRemoteClusterInfo} from '@mm-redux/actions/remote_cluster';
import Preferences from '@mm-redux/constants/preferences';
import {getBotAccounts} from '@mm-redux/selectors/entities/bots';
import {getConfig} from '@mm-redux/selectors/entities/general';
import {getTeammateNameDisplaySetting, getTheme, getBool} from '@mm-redux/selectors/entities/preferences';
import {isTimezoneEnabled} from '@mm-redux/selectors/entities/timezone';
import {getCurrentUserId} from '@mm-redux/selectors/entities/users';
import {makeGetCustomStatus, isCustomStatusEnabled, isCustomStatusExpired, isCustomStatusExpirySupported} from '@selectors/custom_status';
import UserProfile from './user_profile';
function makeMapStateToProps() {
const getCustomStatus = makeGetCustomStatus();
return (state, ownProps) => {
const config = getConfig(state);
const {createChannel: createChannelRequest} = state.requests.channels;
const isMilitaryTime = getBool(state, Preferences.CATEGORY_DISPLAY_SETTINGS, 'use_military_time');
const enableTimezone = isTimezoneEnabled(state);
const user = state.entities.users.profiles[ownProps.userId];
const customStatusEnabled = isCustomStatusEnabled(state);
const customStatus = customStatusEnabled ? getCustomStatus(state, user?.id) : undefined;
return {
config,
createChannelRequest,
currentDisplayName: state.views.channel.displayName,
user,
bot: getBotAccounts(state)[ownProps.userId],
teammateNameDisplay: getTeammateNameDisplaySetting(state),
enableTimezone,
isMilitaryTime,
theme: getTheme(state),
isMyUser: getCurrentUserId(state) === ownProps.userId,
remoteClusterInfo: state.entities.remoteCluster.info[user?.remote_id],
customStatus,
isCustomStatusExpired: customStatusEnabled ? isCustomStatusExpired(state, customStatus) : true,
isCustomStatusExpirySupported: customStatusEnabled ? isCustomStatusExpirySupported(state) : false,
};
};
}
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
makeDirectChannel,
setChannelDisplayName,
loadBot,
getRemoteClusterInfo,
unsetCustomStatus,
}, dispatch),
};
}
export default connect(makeMapStateToProps, mapDispatchToProps)(UserProfile);