|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
import api from '../api';
|
|
|
|
|
import { emojiIndex } from 'emoji-mart';
|
|
|
|
|
import { throttle } from 'lodash';
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
updateTimeline,
|
|
|
|
@ -247,14 +248,7 @@ export function clearComposeSuggestions() {
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export function fetchComposeSuggestions(token) {
|
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
|
if (token[0] === ':') {
|
|
|
|
|
const results = emojiIndex.search(token.replace(':', ''), { maxResults: 3 });
|
|
|
|
|
dispatch(readyComposeSuggestionsEmojis(token, results));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const fetchComposeSuggestionsAccounts = throttle((dispatch, getState, token) => {
|
|
|
|
|
api(getState).get('/api/v1/accounts/search', {
|
|
|
|
|
params: {
|
|
|
|
|
q: token.slice(1),
|
|
|
|
@ -264,6 +258,20 @@ export function fetchComposeSuggestions(token) {
|
|
|
|
|
}).then(response => {
|
|
|
|
|
dispatch(readyComposeSuggestionsAccounts(token, response.data));
|
|
|
|
|
});
|
|
|
|
|
}, 200, { leading: true, trailing: true });
|
|
|
|
|
|
|
|
|
|
const fetchComposeSuggestionsEmojis = (dispatch, getState, token) => {
|
|
|
|
|
const results = emojiIndex.search(token.replace(':', ''), { maxResults: 5 });
|
|
|
|
|
dispatch(readyComposeSuggestionsEmojis(token, results));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export function fetchComposeSuggestions(token) {
|
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
|
if (token[0] === ':') {
|
|
|
|
|
fetchComposeSuggestionsEmojis(dispatch, getState, token);
|
|
|
|
|
} else {
|
|
|
|
|
fetchComposeSuggestionsAccounts(dispatch, getState, token);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|