Fix force completion and hide rooms with no alias

This commit is contained in:
Aviral Dasgupta 2016-09-13 18:02:33 +05:30
parent 9a991a4dfd
commit 79e5e6f6fe
3 changed files with 10 additions and 4 deletions

View File

@ -44,7 +44,7 @@ export default class RoomProvider extends AutocompleteProvider {
),
range,
};
}).slice(0, 4);
}).filter(completion => !!completion.completion && completion.completion.length > 0).slice(0, 4);
}
return completions;
}

View File

@ -5,6 +5,7 @@ import flatMap from 'lodash/flatMap';
import isEqual from 'lodash/isEqual';
import sdk from '../../../index';
import type {Completion, SelectionRange} from '../../../autocomplete/Autocompleter';
import Q from 'q';
import {getCompletions} from '../../../autocomplete/Autocompleter';
@ -140,12 +141,15 @@ export default class Autocomplete extends React.Component {
}
forceComplete() {
const done = Q.defer();
this.setState({
forceComplete: true,
}, () => {
this.complete(this.props.query, this.props.selection);
setTimeout(() => this.onDownArrow(), 50); // FIXME HACK
this.complete(this.props.query, this.props.selection).then(() => {
done.resolve();
});
});
return done.promise;
}
/** called from MessageComposerInput

View File

@ -595,7 +595,9 @@ export default class MessageComposerInput extends React.Component {
e.preventDefault(); // we *never* want tab's default to happen, but we do want up/down sometimes
const didTab = await (e.shiftKey ? this.onUpArrow : this.onDownArrow)(e);
if (!didTab && this.autocomplete) {
this.autocomplete.forceComplete();
this.autocomplete.forceComplete().then(() => {
this.onDownArrow(e);
});
}
}