mirror of https://github.com/vector-im/riot-web
Merge pull request #1219 from matrix-org/luke/fix-autcompleter-promises
Fix Autocompleter promisespull/21833/head
commit
7945abe6b9
|
@ -52,21 +52,24 @@ export async function getCompletions(query: string, selection: SelectionRange, f
|
||||||
otherwise, we run into a condition where new completions are displayed
|
otherwise, we run into a condition where new completions are displayed
|
||||||
while the user is interacting with the list, which makes it difficult
|
while the user is interacting with the list, which makes it difficult
|
||||||
to predict whether an action will actually do what is intended
|
to predict whether an action will actually do what is intended
|
||||||
|
*/
|
||||||
It ends up containing a list of Q promise states, which are objects with
|
const completionsList = await Promise.all(
|
||||||
state (== "fulfilled" || "rejected") and value. */
|
// Array of inspections of promises that might timeout. Instead of allowing a
|
||||||
const completionsList = await Q.allSettled(
|
// single timeout to reject the Promise.all, reflect each one and once they've all
|
||||||
PROVIDERS.map(provider => {
|
// settled, filter for the fulfilled ones
|
||||||
return Promise.resolve(provider.getCompletions(query, selection, force))
|
PROVIDERS.map((provider) => {
|
||||||
.timeout(PROVIDER_COMPLETION_TIMEOUT);
|
return provider
|
||||||
|
.getCompletions(query, selection, force)
|
||||||
|
.timeout(PROVIDER_COMPLETION_TIMEOUT)
|
||||||
|
.reflect();
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
return completionsList
|
return completionsList.filter(
|
||||||
.filter(completion => completion.state === "fulfilled")
|
(inspection) => inspection.isFulfilled(),
|
||||||
.map((completionsState, i) => {
|
).map((completionsState, i) => {
|
||||||
return {
|
return {
|
||||||
completions: completionsState.value,
|
completions: completionsState.value(),
|
||||||
provider: PROVIDERS[i],
|
provider: PROVIDERS[i],
|
||||||
|
|
||||||
/* the currently matched "command" the completer tried to complete
|
/* the currently matched "command" the completer tried to complete
|
||||||
|
|
Loading…
Reference in New Issue