diff options
author | ThibG <thib@sitedethib.com> | 2018-03-20 12:40:12 +0100 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2018-03-20 12:40:12 +0100 |
commit | a5c6c748e096f61d00bbd778a263e22117e1ae9f (patch) | |
tree | e1c2ad5588ec6f67dd3e7fe627a189101db98d56 /app/javascript | |
parent | 36b57037961383466b7f5c20b39ee68cd9f202a0 (diff) |
Cancel outdated pending compose suggestions (#6838)
Diffstat (limited to 'app/javascript')
-rw-r--r-- | app/javascript/mastodon/actions/compose.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/app/javascript/mastodon/actions/compose.js b/app/javascript/mastodon/actions/compose.js index 130b4af23..1371f22b2 100644 --- a/app/javascript/mastodon/actions/compose.js +++ b/app/javascript/mastodon/actions/compose.js @@ -1,4 +1,5 @@ import api from '../api'; +import { CancelToken } from 'axios'; import { throttle } from 'lodash'; import { search as emojiSearch } from '../features/emoji/emoji_mart_search_light'; import { tagHistory } from '../settings'; @@ -11,6 +12,8 @@ import { refreshPublicTimeline, } from './timelines'; +let cancelFetchComposeSuggestionsAccounts; + export const COMPOSE_CHANGE = 'COMPOSE_CHANGE'; export const COMPOSE_SUBMIT_REQUEST = 'COMPOSE_SUBMIT_REQUEST'; export const COMPOSE_SUBMIT_SUCCESS = 'COMPOSE_SUBMIT_SUCCESS'; @@ -257,13 +260,22 @@ export function undoUploadCompose(media_id) { }; export function clearComposeSuggestions() { + if (cancelFetchComposeSuggestionsAccounts) { + cancelFetchComposeSuggestionsAccounts(); + } return { type: COMPOSE_SUGGESTIONS_CLEAR, }; }; const fetchComposeSuggestionsAccounts = throttle((dispatch, getState, token) => { + if (cancelFetchComposeSuggestionsAccounts) { + cancelFetchComposeSuggestionsAccounts(); + } api(getState).get('/api/v1/accounts/search', { + cancelToken: new CancelToken(cancel => { + cancelFetchComposeSuggestionsAccounts = cancel; + }), params: { q: token.slice(1), resolve: false, |