diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2016-05-31 16:14:28 -0400 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2016-05-31 16:14:28 -0400 |
commit | 12f659372786c9b9dd3261b4663a4e840da64372 (patch) | |
tree | ed7b3234df9ef277fa79759ced5897cc59e83049 /webapp/components/suggestion/search_channel_provider.jsx | |
parent | 6e6257fccaa0c5837101dedbe7f547bc3cc6c6bb (diff) | |
download | chat-12f659372786c9b9dd3261b4663a4e840da64372.tar.gz chat-12f659372786c9b9dd3261b4663a4e840da64372.tar.bz2 chat-12f659372786c9b9dd3261b4663a4e840da64372.zip |
PLT-2643 Fixed asynchronous autocomplete incorrectly replacing text (#3167)
* Allowed different suggestions to match different text. Added a Suggestion base component. Improved text replacement used when filling in suggestions
* Fixed formatting
Diffstat (limited to 'webapp/components/suggestion/search_channel_provider.jsx')
-rw-r--r-- | webapp/components/suggestion/search_channel_provider.jsx | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/webapp/components/suggestion/search_channel_provider.jsx b/webapp/components/suggestion/search_channel_provider.jsx index 2e3195c1d..2b8005204 100644 --- a/webapp/components/suggestion/search_channel_provider.jsx +++ b/webapp/components/suggestion/search_channel_provider.jsx @@ -1,13 +1,15 @@ // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. +import React from 'react'; + import ChannelStore from 'stores/channel_store.jsx'; import Constants from 'utils/constants.jsx'; import SuggestionStore from 'stores/suggestion_store.jsx'; -import React from 'react'; +import Suggestion from './suggestion.jsx'; -class SearchChannelSuggestion extends React.Component { +class SearchChannelSuggestion extends Suggestion { render() { const {item, isSelection, onClick} = this.props; @@ -27,12 +29,6 @@ class SearchChannelSuggestion extends React.Component { } } -SearchChannelSuggestion.propTypes = { - item: React.PropTypes.object.isRequired, - isSelection: React.PropTypes.bool, - onClick: React.PropTypes.func -}; - export default class SearchChannelProvider { handlePretextChanged(suggestionId, pretext) { const captured = (/\b(?:in|channel):\s*(\S*)$/i).exec(pretext); @@ -62,10 +58,8 @@ export default class SearchChannelProvider { privateChannels.sort((a, b) => a.name.localeCompare(b.name)); const privateChannelNames = privateChannels.map((channel) => channel.name); - SuggestionStore.setMatchedPretext(suggestionId, channelPrefix); - - SuggestionStore.addSuggestions(suggestionId, publicChannelNames, publicChannels, SearchChannelSuggestion); - SuggestionStore.addSuggestions(suggestionId, privateChannelNames, privateChannels, SearchChannelSuggestion); + SuggestionStore.addSuggestions(suggestionId, publicChannelNames, publicChannels, SearchChannelSuggestion, channelPrefix); + SuggestionStore.addSuggestions(suggestionId, privateChannelNames, privateChannels, SearchChannelSuggestion, channelPrefix); } } } |