|
|
@ -1,18 +1,20 @@
|
|
|
|
import api from '../api';
|
|
|
|
import { isCancel } from 'axios';
|
|
|
|
import { CancelToken, isCancel } from 'axios';
|
|
|
|
|
|
|
|
import { throttle } from 'lodash';
|
|
|
|
import { throttle } from 'lodash';
|
|
|
|
import { search as emojiSearch } from '../features/emoji/emoji_mart_search_light';
|
|
|
|
import { defineMessages } from 'react-intl';
|
|
|
|
import { tagHistory } from '../settings';
|
|
|
|
import api from 'mastodon/api';
|
|
|
|
|
|
|
|
import { search as emojiSearch } from 'mastodon/features/emoji/emoji_mart_search_light';
|
|
|
|
|
|
|
|
import { tagHistory } from 'mastodon/settings';
|
|
|
|
|
|
|
|
import resizeImage from 'mastodon/utils/resize_image';
|
|
|
|
|
|
|
|
import { showAlert, showAlertForError } from './alerts';
|
|
|
|
import { useEmoji } from './emojis';
|
|
|
|
import { useEmoji } from './emojis';
|
|
|
|
import resizeImage from '../utils/resize_image';
|
|
|
|
|
|
|
|
import { importFetchedAccounts } from './importer';
|
|
|
|
import { importFetchedAccounts } from './importer';
|
|
|
|
import { updateTimeline } from './timelines';
|
|
|
|
|
|
|
|
import { showAlertForError } from './alerts';
|
|
|
|
|
|
|
|
import { showAlert } from './alerts';
|
|
|
|
|
|
|
|
import { openModal } from './modal';
|
|
|
|
import { openModal } from './modal';
|
|
|
|
import { defineMessages } from 'react-intl';
|
|
|
|
import { updateTimeline } from './timelines';
|
|
|
|
|
|
|
|
|
|
|
|
let cancelFetchComposeSuggestionsAccounts, cancelFetchComposeSuggestionsTags;
|
|
|
|
/** @type {AbortController | undefined} */
|
|
|
|
|
|
|
|
let fetchComposeSuggestionsAccountsController;
|
|
|
|
|
|
|
|
/** @type {AbortController | undefined} */
|
|
|
|
|
|
|
|
let fetchComposeSuggestionsTagsController;
|
|
|
|
|
|
|
|
|
|
|
|
export const COMPOSE_CHANGE = 'COMPOSE_CHANGE';
|
|
|
|
export const COMPOSE_CHANGE = 'COMPOSE_CHANGE';
|
|
|
|
export const COMPOSE_SUBMIT_REQUEST = 'COMPOSE_SUBMIT_REQUEST';
|
|
|
|
export const COMPOSE_SUBMIT_REQUEST = 'COMPOSE_SUBMIT_REQUEST';
|
|
|
@ -433,8 +435,8 @@ export function undoUploadCompose(media_id) {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export function clearComposeSuggestions() {
|
|
|
|
export function clearComposeSuggestions() {
|
|
|
|
if (cancelFetchComposeSuggestionsAccounts) {
|
|
|
|
if (fetchComposeSuggestionsAccountsController) {
|
|
|
|
cancelFetchComposeSuggestionsAccounts();
|
|
|
|
fetchComposeSuggestionsAccountsController.abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
type: COMPOSE_SUGGESTIONS_CLEAR,
|
|
|
|
type: COMPOSE_SUGGESTIONS_CLEAR,
|
|
|
@ -442,14 +444,14 @@ export function clearComposeSuggestions() {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const fetchComposeSuggestionsAccounts = throttle((dispatch, getState, token) => {
|
|
|
|
const fetchComposeSuggestionsAccounts = throttle((dispatch, getState, token) => {
|
|
|
|
if (cancelFetchComposeSuggestionsAccounts) {
|
|
|
|
if (fetchComposeSuggestionsAccountsController) {
|
|
|
|
cancelFetchComposeSuggestionsAccounts();
|
|
|
|
fetchComposeSuggestionsAccountsController.abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fetchComposeSuggestionsAccountsController = new AbortController();
|
|
|
|
|
|
|
|
|
|
|
|
api(getState).get('/api/v1/accounts/search', {
|
|
|
|
api(getState).get('/api/v1/accounts/search', {
|
|
|
|
cancelToken: new CancelToken(cancel => {
|
|
|
|
signal: fetchComposeSuggestionsAccountsController.signal,
|
|
|
|
cancelFetchComposeSuggestionsAccounts = cancel;
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
params: {
|
|
|
|
params: {
|
|
|
|
q: token.slice(1),
|
|
|
|
q: token.slice(1),
|
|
|
@ -472,16 +474,16 @@ const fetchComposeSuggestionsEmojis = (dispatch, getState, token) => {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const fetchComposeSuggestionsTags = throttle((dispatch, getState, token) => {
|
|
|
|
const fetchComposeSuggestionsTags = throttle((dispatch, getState, token) => {
|
|
|
|
if (cancelFetchComposeSuggestionsTags) {
|
|
|
|
if (fetchComposeSuggestionsTagsController) {
|
|
|
|
cancelFetchComposeSuggestionsTags();
|
|
|
|
fetchComposeSuggestionsTagsController.abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dispatch(updateSuggestionTags(token));
|
|
|
|
dispatch(updateSuggestionTags(token));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fetchComposeSuggestionsTagsController = new AbortController();
|
|
|
|
|
|
|
|
|
|
|
|
api(getState).get('/api/v2/search', {
|
|
|
|
api(getState).get('/api/v2/search', {
|
|
|
|
cancelToken: new CancelToken(cancel => {
|
|
|
|
signal: fetchComposeSuggestionsTagsController.signal,
|
|
|
|
cancelFetchComposeSuggestionsTags = cancel;
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
params: {
|
|
|
|
params: {
|
|
|
|
type: 'hashtags',
|
|
|
|
type: 'hashtags',
|
|
|
|