diff options
author | Christopher Speller <crspeller@gmail.com> | 2017-09-06 23:04:13 -0700 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2017-09-06 23:11:58 -0700 |
commit | d8bd57901e33a7057e26e782e295099ffcc0da89 (patch) | |
tree | e12dfc8cad42b1576756d19d7fbfd82646a009bf /webapp/components/suggestion/search_channel_provider.jsx | |
parent | 7bc8e9a08dfde56387f946fdf5086252aa4d0491 (diff) | |
download | chat-d8bd57901e33a7057e26e782e295099ffcc0da89.tar.gz chat-d8bd57901e33a7057e26e782e295099ffcc0da89.tar.bz2 chat-d8bd57901e33a7057e26e782e295099ffcc0da89.zip |
Removing webapp
Diffstat (limited to 'webapp/components/suggestion/search_channel_provider.jsx')
-rw-r--r-- | webapp/components/suggestion/search_channel_provider.jsx | 91 |
1 files changed, 0 insertions, 91 deletions
diff --git a/webapp/components/suggestion/search_channel_provider.jsx b/webapp/components/suggestion/search_channel_provider.jsx deleted file mode 100644 index 650ec6973..000000000 --- a/webapp/components/suggestion/search_channel_provider.jsx +++ /dev/null @@ -1,91 +0,0 @@ -// 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 {autocompleteChannels} from 'actions/channel_actions.jsx'; - -import ChannelStore from 'stores/channel_store.jsx'; - -import AppDispatcher from 'dispatcher/app_dispatcher.jsx'; -import {Constants, ActionTypes} from 'utils/constants.jsx'; -import {sortChannelsByDisplayName} from 'utils/channel_utils.jsx'; - -import React from 'react'; - -class SearchChannelSuggestion extends Suggestion { - render() { - const {item, isSelection} = this.props; - - let className = 'search-autocomplete__item'; - if (isSelection) { - className += ' selected'; - } - - return ( - <div - onClick={this.handleClick} - className={className} - > - <i className='fa fa fa-plus-square'/>{item.name} - </div> - ); - } -} - -export default class SearchChannelProvider extends Provider { - handlePretextChanged(suggestionId, pretext) { - const captured = (/\b(?:in|channel):\s*(\S*)$/i).exec(pretext.toLowerCase()); - if (captured) { - const channelPrefix = captured[1]; - - this.startNewRequest(suggestionId, channelPrefix); - - autocompleteChannels( - channelPrefix, - (data) => { - if (this.shouldCancelDispatch(channelPrefix)) { - return; - } - - const publicChannels = data; - - const localChannels = ChannelStore.getAll(); - let privateChannels = []; - - for (const id of Object.keys(localChannels)) { - const channel = localChannels[id]; - if (channel.name.startsWith(channelPrefix) && channel.type === Constants.PRIVATE_CHANNEL) { - privateChannels.push(channel); - } - } - - let filteredPublicChannels = []; - publicChannels.forEach((item) => { - if (item.name.startsWith(channelPrefix)) { - filteredPublicChannels.push(item); - } - }); - - privateChannels = privateChannels.sort(sortChannelsByDisplayName); - filteredPublicChannels = filteredPublicChannels.sort(sortChannelsByDisplayName); - - const channels = filteredPublicChannels.concat(privateChannels); - const channelNames = channels.map((channel) => channel.name); - - AppDispatcher.handleServerAction({ - type: ActionTypes.SUGGESTION_RECEIVED_SUGGESTIONS, - id: suggestionId, - matchedPretext: channelPrefix, - terms: channelNames, - items: channels, - component: SearchChannelSuggestion - }); - } - ); - } - - return Boolean(captured); - } -} |