// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import Suggestion from './suggestion.jsx'; import Provider from './provider.jsx'; import Client from 'client/web_client.jsx'; import AppDispatcher from 'dispatcher/app_dispatcher.jsx'; import {Constants, ActionTypes} from 'utils/constants.jsx'; import * as Utils from 'utils/utils.jsx'; import {sortChannelsByDisplayName, getChannelDisplayName} from 'utils/channel_utils.jsx'; import React from 'react'; import store from 'stores/redux_store.jsx'; const getState = store.getState; import {Client4} from 'mattermost-redux/client'; import {getCurrentUserId, searchProfiles} from 'mattermost-redux/selectors/entities/users'; import {getChannelsInCurrentTeam, getMyChannelMemberships, getGroupChannels} from 'mattermost-redux/selectors/entities/channels'; import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams'; import {getBool} from 'mattermost-redux/selectors/entities/preferences'; import {Preferences} from 'mattermost-redux/constants'; class SwitchChannelSuggestion extends Suggestion { render() { const {item, isSelection} = this.props; const channel = item.channel; let className = 'mentions__name'; if (isSelection) { className += ' suggestion--selected'; } let displayName = channel.display_name; let icon = null; if (channel.type === Constants.OPEN_CHANNEL) { icon =
; } else if (channel.type === Constants.PRIVATE_CHANNEL) { icon =
; } else if (channel.type === Constants.GM_CHANNEL) { displayName = getChannelDisplayName(channel); icon =
{'G'}
; } else { icon = (
wrappedChannel.channel.name); if (skipNotInChannel) { channels.push({ type: Constants.MENTION_MORE_CHANNELS, loading: true }); } setTimeout(() => { AppDispatcher.handleServerAction({ type: ActionTypes.SUGGESTION_RECEIVED_SUGGESTIONS, id: suggestionId, matchedPretext: channelPrefix, terms: channelNames, items: channels, component: SwitchChannelSuggestion }); }, 0); } }