Remove autocomplete delay (#4819)
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
d4b890fff1
Коммит
bf3fec604f
@@ -4,7 +4,6 @@
|
||||
import Suggestion from './suggestion.jsx';
|
||||
|
||||
import ChannelStore from 'stores/channel_store.jsx';
|
||||
import SuggestionStore from 'stores/suggestion_store.jsx';
|
||||
|
||||
import {autocompleteUsersInChannel} from 'actions/user_actions.jsx';
|
||||
|
||||
@@ -104,32 +103,13 @@ class AtMentionSuggestion extends Suggestion {
|
||||
export default class AtMentionProvider {
|
||||
constructor(channelId) {
|
||||
this.channelId = channelId;
|
||||
this.timeoutId = '';
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.clearTimeout(this.timeoutId);
|
||||
}
|
||||
|
||||
clearTimeout() {
|
||||
if (this.timeoutId) {
|
||||
clearTimeout(this.timeoutId);
|
||||
this.timeoutId = '';
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
handlePretextChanged(suggestionId, pretext) {
|
||||
const hadSuggestions = this.clearTimeout(this.timeoutId);
|
||||
|
||||
const captured = XRegExp.cache('(?:^|\\W)@([\\pL\\d\\-_.]*)$', 'i').exec(pretext.toLowerCase());
|
||||
if (captured) {
|
||||
const prefix = captured[1];
|
||||
|
||||
function autocomplete() {
|
||||
autocompleteUsersInChannel(
|
||||
prefix,
|
||||
this.channelId,
|
||||
@@ -167,16 +147,5 @@ export default class AtMentionProvider {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
this.timeoutId = setTimeout(
|
||||
autocomplete.bind(this),
|
||||
Constants.AUTOCOMPLETE_TIMEOUT
|
||||
);
|
||||
}
|
||||
|
||||
if (hadSuggestions) {
|
||||
// Clear the suggestions since the user has now typed something invalid
|
||||
SuggestionStore.clearSuggestions(suggestionId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,20 +50,11 @@ class ChannelMentionSuggestion extends Suggestion {
|
||||
}
|
||||
|
||||
export default class ChannelMentionProvider {
|
||||
constructor() {
|
||||
this.timeoutId = '';
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
clearTimeout(this.timeoutId);
|
||||
}
|
||||
|
||||
handlePretextChanged(suggestionId, pretext) {
|
||||
const captured = (/(^|\s)(~([^~]*))$/i).exec(pretext.toLowerCase());
|
||||
if (captured) {
|
||||
const prefix = captured[3];
|
||||
|
||||
function autocomplete() {
|
||||
autocompleteChannels(
|
||||
prefix,
|
||||
(data) => {
|
||||
@@ -109,11 +100,5 @@ export default class ChannelMentionProvider {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
this.timeoutId = setTimeout(
|
||||
autocomplete.bind(this),
|
||||
Constants.AUTOCOMPLETE_TIMEOUT
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,20 +33,11 @@ class SearchChannelSuggestion extends Suggestion {
|
||||
}
|
||||
|
||||
export default class SearchChannelProvider {
|
||||
constructor() {
|
||||
this.timeoutId = '';
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
clearTimeout(this.timeoutId);
|
||||
}
|
||||
|
||||
handlePretextChanged(suggestionId, pretext) {
|
||||
const captured = (/\b(?:in|channel):\s*(\S*)$/i).exec(pretext.toLowerCase());
|
||||
if (captured) {
|
||||
const channelPrefix = captured[1];
|
||||
|
||||
function autocomplete() {
|
||||
autocompleteChannels(
|
||||
channelPrefix,
|
||||
(data) => {
|
||||
@@ -86,11 +77,5 @@ export default class SearchChannelProvider {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
this.timeoutId = setTimeout(
|
||||
autocomplete.bind(this),
|
||||
Constants.AUTOCOMPLETE_TIMEOUT
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import {autocompleteUsersInTeam} from 'actions/user_actions.jsx';
|
||||
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
|
||||
import Client from 'client/web_client.jsx';
|
||||
import * as Utils from 'utils/utils.jsx';
|
||||
import {Constants, ActionTypes} from 'utils/constants.jsx';
|
||||
import {ActionTypes} from 'utils/constants.jsx';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
@@ -57,22 +57,11 @@ class SearchUserSuggestion extends Suggestion {
|
||||
}
|
||||
|
||||
export default class SearchUserProvider {
|
||||
constructor() {
|
||||
this.timeoutId = '';
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
clearTimeout(this.timeoutId);
|
||||
}
|
||||
|
||||
handlePretextChanged(suggestionId, pretext) {
|
||||
clearTimeout(this.timeoutId);
|
||||
|
||||
const captured = (/\bfrom:\s*(\S*)$/i).exec(pretext.toLowerCase());
|
||||
if (captured) {
|
||||
const usernamePrefix = captured[1];
|
||||
|
||||
function autocomplete() {
|
||||
autocompleteUsersInTeam(
|
||||
usernamePrefix,
|
||||
(data) => {
|
||||
@@ -90,11 +79,5 @@ export default class SearchUserProvider {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
this.timeoutId = setTimeout(
|
||||
autocomplete.bind(this),
|
||||
Constants.AUTOCOMPLETE_TIMEOUT
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,20 +59,11 @@ class SwitchChannelSuggestion extends Suggestion {
|
||||
}
|
||||
|
||||
export default class SwitchChannelProvider {
|
||||
constructor() {
|
||||
this.timeoutId = '';
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
clearTimeout(this.timeoutId);
|
||||
}
|
||||
|
||||
handlePretextChanged(suggestionId, channelPrefix) {
|
||||
if (channelPrefix) {
|
||||
const allChannels = ChannelStore.getAll();
|
||||
const channels = [];
|
||||
|
||||
function autocomplete() {
|
||||
autocompleteUsers(
|
||||
channelPrefix,
|
||||
(users) => {
|
||||
@@ -143,11 +134,5 @@ export default class SwitchChannelProvider {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
this.timeoutId = setTimeout(
|
||||
autocomplete.bind(this),
|
||||
Constants.AUTOCOMPLETE_TIMEOUT
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -865,7 +865,6 @@ export const Constants = {
|
||||
MENTION_SPECIAL: 'mention.special',
|
||||
DEFAULT_NOTIFICATION_DURATION: 5000,
|
||||
STATUS_INTERVAL: 60000,
|
||||
AUTOCOMPLETE_TIMEOUT: 100,
|
||||
SEARCH_TIMEOUT_MILLISECONDS: 100
|
||||
};
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user