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