Merge pull request #2087 from hmhealey/plt1758
PLT-1758 Changed CommandProvider to only set the matched pretext if it actuall…
Этот коммит содержится в:
@@ -2,7 +2,6 @@
|
|||||||
// See License.txt for license information.
|
// See License.txt for license information.
|
||||||
|
|
||||||
import * as AsyncClient from '../../utils/async_client.jsx';
|
import * as AsyncClient from '../../utils/async_client.jsx';
|
||||||
import SuggestionStore from '../../stores/suggestion_store.jsx';
|
|
||||||
|
|
||||||
class CommandSuggestion extends React.Component {
|
class CommandSuggestion extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
@@ -38,8 +37,6 @@ CommandSuggestion.propTypes = {
|
|||||||
export default class CommandProvider {
|
export default class CommandProvider {
|
||||||
handlePretextChanged(suggestionId, pretext) {
|
handlePretextChanged(suggestionId, pretext) {
|
||||||
if (pretext.startsWith('/')) {
|
if (pretext.startsWith('/')) {
|
||||||
SuggestionStore.setMatchedPretext(suggestionId, pretext);
|
|
||||||
|
|
||||||
AsyncClient.getSuggestedCommands(pretext, suggestionId, CommandSuggestion);
|
AsyncClient.getSuggestedCommands(pretext, suggestionId, CommandSuggestion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -223,7 +223,9 @@ class SuggestionStore extends EventEmitter {
|
|||||||
this.emitSuggestionsChanged(id);
|
this.emitSuggestionsChanged(id);
|
||||||
break;
|
break;
|
||||||
case ActionTypes.SUGGESTION_RECEIVED_SUGGESTIONS:
|
case ActionTypes.SUGGESTION_RECEIVED_SUGGESTIONS:
|
||||||
if (other.matchedPretext === this.getMatchedPretext(id)) {
|
if (this.getMatchedPretext(id) === '') {
|
||||||
|
this.setMatchedPretext(id, other.matchedPretext);
|
||||||
|
|
||||||
// ensure the matched pretext hasn't changed so that we don't receive suggestions for outdated pretext
|
// ensure the matched pretext hasn't changed so that we don't receive suggestions for outdated pretext
|
||||||
this.addSuggestions(id, other.terms, other.items, other.component);
|
this.addSuggestions(id, other.terms, other.items, other.component);
|
||||||
|
|
||||||
|
|||||||
@@ -789,14 +789,16 @@ export function getSuggestedCommands(command, suggestionId, component) {
|
|||||||
// pull out the suggested commands from the returned data
|
// pull out the suggested commands from the returned data
|
||||||
const terms = matches.map((suggestion) => suggestion.suggestion);
|
const terms = matches.map((suggestion) => suggestion.suggestion);
|
||||||
|
|
||||||
AppDispatcher.handleServerAction({
|
if (terms.length > 0) {
|
||||||
type: ActionTypes.SUGGESTION_RECEIVED_SUGGESTIONS,
|
AppDispatcher.handleServerAction({
|
||||||
id: suggestionId,
|
type: ActionTypes.SUGGESTION_RECEIVED_SUGGESTIONS,
|
||||||
matchedPretext: command,
|
id: suggestionId,
|
||||||
terms,
|
matchedPretext: command,
|
||||||
items: matches,
|
terms,
|
||||||
component
|
items: matches,
|
||||||
});
|
component
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
dispatchError(err, 'getCommandSuggestions');
|
dispatchError(err, 'getCommandSuggestions');
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user