* Remove mattermost-redux * Move mm-redux files into app/redux * Add @redux path to tsconfig.json * Fix imports * Install missing dependencies * Fix tsc errors * Fix i18n_utils test * Fix more imports * Remove redux websocket * Fix tests * Rename @redux * Apply changes from mattermost-redux PR 1103 * Remove mattermost-redux mention in template * Add missing imports * Rename app/redux/ to app/mm-redux/ * Remove test file * Fix fetching Sidebar GM profiles Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
43 lines
1.4 KiB
JavaScript
43 lines
1.4 KiB
JavaScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import {connect} from 'react-redux';
|
|
|
|
import {General} from '@mm-redux/constants';
|
|
import {getChannel} from '@mm-redux/selectors/entities/channels';
|
|
import {getTheme} from '@mm-redux/selectors/entities/preferences';
|
|
import {getUser} from '@mm-redux/selectors/entities/users';
|
|
|
|
import {getChannelNameForSearchAutocomplete} from 'app/selectors/channel';
|
|
import {isLandscape} from 'app/selectors/device';
|
|
import {isGuest as isGuestUser} from 'app/utils/users';
|
|
|
|
import ChannelMentionItem from './channel_mention_item';
|
|
|
|
function mapStateToProps(state, ownProps) {
|
|
const channel = getChannel(state, ownProps.channelId);
|
|
let displayName = getChannelNameForSearchAutocomplete(state, ownProps.channelId);
|
|
|
|
let isBot = false;
|
|
let isGuest = false;
|
|
if (channel?.type === General.DM_CHANNEL) {
|
|
const teammate = getUser(state, channel.teammate_id);
|
|
if (teammate) {
|
|
displayName = teammate.username;
|
|
isBot = teammate.is_bot || false;
|
|
isGuest = isGuestUser(teammate) || false;
|
|
}
|
|
}
|
|
|
|
return {
|
|
displayName,
|
|
name: channel?.name,
|
|
type: channel?.type,
|
|
isBot,
|
|
isGuest,
|
|
theme: getTheme(state),
|
|
isLandscape: isLandscape(state),
|
|
};
|
|
}
|
|
|
|
export default connect(mapStateToProps)(ChannelMentionItem);
|