|
|
@ -105,6 +105,7 @@ const setComposeToStatus = (status: Status, rawText: string, spoilerText?: strin
|
|
|
|
|
|
|
|
|
|
|
|
dispatch({
|
|
|
|
dispatch({
|
|
|
|
type: COMPOSE_SET_STATUS,
|
|
|
|
type: COMPOSE_SET_STATUS,
|
|
|
|
|
|
|
|
id: 'compose-modal',
|
|
|
|
status,
|
|
|
|
status,
|
|
|
|
rawText,
|
|
|
|
rawText,
|
|
|
|
explicitAddressing,
|
|
|
|
explicitAddressing,
|
|
|
@ -129,6 +130,7 @@ const replyCompose = (status: Status) =>
|
|
|
|
|
|
|
|
|
|
|
|
dispatch({
|
|
|
|
dispatch({
|
|
|
|
type: COMPOSE_REPLY,
|
|
|
|
type: COMPOSE_REPLY,
|
|
|
|
|
|
|
|
id: 'compose-modal',
|
|
|
|
status: status,
|
|
|
|
status: status,
|
|
|
|
account: state.accounts.get(state.me),
|
|
|
|
account: state.accounts.get(state.me),
|
|
|
|
explicitAddressing,
|
|
|
|
explicitAddressing,
|
|
|
@ -139,6 +141,7 @@ const replyCompose = (status: Status) =>
|
|
|
|
|
|
|
|
|
|
|
|
const cancelReplyCompose = () => ({
|
|
|
|
const cancelReplyCompose = () => ({
|
|
|
|
type: COMPOSE_REPLY_CANCEL,
|
|
|
|
type: COMPOSE_REPLY_CANCEL,
|
|
|
|
|
|
|
|
id: 'compose-modal',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const quoteCompose = (status: Status) =>
|
|
|
|
const quoteCompose = (status: Status) =>
|
|
|
@ -149,6 +152,7 @@ const quoteCompose = (status: Status) =>
|
|
|
|
|
|
|
|
|
|
|
|
dispatch({
|
|
|
|
dispatch({
|
|
|
|
type: COMPOSE_QUOTE,
|
|
|
|
type: COMPOSE_QUOTE,
|
|
|
|
|
|
|
|
id: 'compose-modal',
|
|
|
|
status: status,
|
|
|
|
status: status,
|
|
|
|
account: state.accounts.get(state.me),
|
|
|
|
account: state.accounts.get(state.me),
|
|
|
|
explicitAddressing,
|
|
|
|
explicitAddressing,
|
|
|
@ -159,16 +163,19 @@ const quoteCompose = (status: Status) =>
|
|
|
|
|
|
|
|
|
|
|
|
const cancelQuoteCompose = () => ({
|
|
|
|
const cancelQuoteCompose = () => ({
|
|
|
|
type: COMPOSE_QUOTE_CANCEL,
|
|
|
|
type: COMPOSE_QUOTE_CANCEL,
|
|
|
|
|
|
|
|
id: 'compose-modal',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const resetCompose = () => ({
|
|
|
|
const resetCompose = (composeId = 'compose-modal') => ({
|
|
|
|
type: COMPOSE_RESET,
|
|
|
|
type: COMPOSE_RESET,
|
|
|
|
|
|
|
|
id: composeId,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const mentionCompose = (account: Account) =>
|
|
|
|
const mentionCompose = (account: Account) =>
|
|
|
|
(dispatch: AppDispatch) => {
|
|
|
|
(dispatch: AppDispatch) => {
|
|
|
|
dispatch({
|
|
|
|
dispatch({
|
|
|
|
type: COMPOSE_MENTION,
|
|
|
|
type: COMPOSE_MENTION,
|
|
|
|
|
|
|
|
id: 'compose-modal',
|
|
|
|
account: account,
|
|
|
|
account: account,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -179,6 +186,7 @@ const directCompose = (account: Account) =>
|
|
|
|
(dispatch: AppDispatch) => {
|
|
|
|
(dispatch: AppDispatch) => {
|
|
|
|
dispatch({
|
|
|
|
dispatch({
|
|
|
|
type: COMPOSE_DIRECT,
|
|
|
|
type: COMPOSE_DIRECT,
|
|
|
|
|
|
|
|
id: 'compose-modal',
|
|
|
|
account: account,
|
|
|
|
account: account,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -191,6 +199,7 @@ const directComposeById = (accountId: string) =>
|
|
|
|
|
|
|
|
|
|
|
|
dispatch({
|
|
|
|
dispatch({
|
|
|
|
type: COMPOSE_DIRECT,
|
|
|
|
type: COMPOSE_DIRECT,
|
|
|
|
|
|
|
|
id: 'compose-modal',
|
|
|
|
account: account,
|
|
|
|
account: account,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -323,7 +332,7 @@ const uploadCompose = (composeId: string, files: FileList, intl: IntlShape) =>
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dispatch(uploadComposeRequest());
|
|
|
|
dispatch(uploadComposeRequest(composeId));
|
|
|
|
|
|
|
|
|
|
|
|
Array.from(files).forEach(async(f, i) => {
|
|
|
|
Array.from(files).forEach(async(f, i) => {
|
|
|
|
if (media.size + i > attachmentLimit - 1) return;
|
|
|
|
if (media.size + i > attachmentLimit - 1) return;
|
|
|
@ -336,18 +345,18 @@ const uploadCompose = (composeId: string, files: FileList, intl: IntlShape) =>
|
|
|
|
const limit = formatBytes(maxImageSize);
|
|
|
|
const limit = formatBytes(maxImageSize);
|
|
|
|
const message = intl.formatMessage(messages.exceededImageSizeLimit, { limit });
|
|
|
|
const message = intl.formatMessage(messages.exceededImageSizeLimit, { limit });
|
|
|
|
dispatch(snackbar.error(message));
|
|
|
|
dispatch(snackbar.error(message));
|
|
|
|
dispatch(uploadComposeFail(true));
|
|
|
|
dispatch(uploadComposeFail(composeId, true));
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
} else if (isVideo && maxVideoSize && (f.size > maxVideoSize)) {
|
|
|
|
} else if (isVideo && maxVideoSize && (f.size > maxVideoSize)) {
|
|
|
|
const limit = formatBytes(maxVideoSize);
|
|
|
|
const limit = formatBytes(maxVideoSize);
|
|
|
|
const message = intl.formatMessage(messages.exceededVideoSizeLimit, { limit });
|
|
|
|
const message = intl.formatMessage(messages.exceededVideoSizeLimit, { limit });
|
|
|
|
dispatch(snackbar.error(message));
|
|
|
|
dispatch(snackbar.error(message));
|
|
|
|
dispatch(uploadComposeFail(true));
|
|
|
|
dispatch(uploadComposeFail(composeId, true));
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
} else if (isVideo && maxVideoDuration && (videoDurationInSeconds > maxVideoDuration)) {
|
|
|
|
} else if (isVideo && maxVideoDuration && (videoDurationInSeconds > maxVideoDuration)) {
|
|
|
|
const message = intl.formatMessage(messages.exceededVideoDurationLimit, { limit: maxVideoDuration });
|
|
|
|
const message = intl.formatMessage(messages.exceededVideoDurationLimit, { limit: maxVideoDuration });
|
|
|
|
dispatch(snackbar.error(message));
|
|
|
|
dispatch(snackbar.error(message));
|
|
|
|
dispatch(uploadComposeFail(true));
|
|
|
|
dispatch(uploadComposeFail(composeId, true));
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -361,7 +370,7 @@ const uploadCompose = (composeId: string, files: FileList, intl: IntlShape) =>
|
|
|
|
|
|
|
|
|
|
|
|
const onUploadProgress = ({ loaded }: any) => {
|
|
|
|
const onUploadProgress = ({ loaded }: any) => {
|
|
|
|
progress[i] = loaded;
|
|
|
|
progress[i] = loaded;
|
|
|
|
dispatch(uploadComposeProgress(progress.reduce((a, v) => a + v, 0), total));
|
|
|
|
dispatch(uploadComposeProgress(composeId, progress.reduce((a, v) => a + v, 0), total));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return dispatch(uploadMedia(data, onUploadProgress))
|
|
|
|
return dispatch(uploadMedia(data, onUploadProgress))
|
|
|
@ -369,98 +378,107 @@ const uploadCompose = (composeId: string, files: FileList, intl: IntlShape) =>
|
|
|
|
// If server-side processing of the media attachment has not completed yet,
|
|
|
|
// If server-side processing of the media attachment has not completed yet,
|
|
|
|
// poll the server until it is, before showing the media attachment as uploaded
|
|
|
|
// poll the server until it is, before showing the media attachment as uploaded
|
|
|
|
if (status === 200) {
|
|
|
|
if (status === 200) {
|
|
|
|
dispatch(uploadComposeSuccess(data, f));
|
|
|
|
dispatch(uploadComposeSuccess(composeId, data, f));
|
|
|
|
} else if (status === 202) {
|
|
|
|
} else if (status === 202) {
|
|
|
|
const poll = () => {
|
|
|
|
const poll = () => {
|
|
|
|
dispatch(fetchMedia(data.id)).then(({ status, data }) => {
|
|
|
|
dispatch(fetchMedia(data.id)).then(({ status, data }) => {
|
|
|
|
if (status === 200) {
|
|
|
|
if (status === 200) {
|
|
|
|
dispatch(uploadComposeSuccess(data, f));
|
|
|
|
dispatch(uploadComposeSuccess(composeId, data, f));
|
|
|
|
} else if (status === 206) {
|
|
|
|
} else if (status === 206) {
|
|
|
|
setTimeout(() => poll(), 1000);
|
|
|
|
setTimeout(() => poll(), 1000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).catch(error => dispatch(uploadComposeFail(error)));
|
|
|
|
}).catch(error => dispatch(uploadComposeFail(composeId, error)));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
poll();
|
|
|
|
poll();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}).catch(error => dispatch(uploadComposeFail(error)));
|
|
|
|
}).catch(error => dispatch(uploadComposeFail(composeId, error)));
|
|
|
|
/* eslint-enable no-loop-func */
|
|
|
|
/* eslint-enable no-loop-func */
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const changeUploadCompose = (id: string, params: Record<string, any>) =>
|
|
|
|
const changeUploadCompose = (composeId: string, id: string, params: Record<string, any>) =>
|
|
|
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
|
|
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
|
|
|
if (!isLoggedIn(getState)) return;
|
|
|
|
if (!isLoggedIn(getState)) return;
|
|
|
|
|
|
|
|
|
|
|
|
dispatch(changeUploadComposeRequest());
|
|
|
|
dispatch(changeUploadComposeRequest(composeId));
|
|
|
|
|
|
|
|
|
|
|
|
dispatch(updateMedia(id, params)).then(response => {
|
|
|
|
dispatch(updateMedia(id, params)).then(response => {
|
|
|
|
dispatch(changeUploadComposeSuccess(response.data));
|
|
|
|
dispatch(changeUploadComposeSuccess(composeId, response.data));
|
|
|
|
}).catch(error => {
|
|
|
|
}).catch(error => {
|
|
|
|
dispatch(changeUploadComposeFail(id, error));
|
|
|
|
dispatch(changeUploadComposeFail(composeId, id, error));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const changeUploadComposeRequest = () => ({
|
|
|
|
const changeUploadComposeRequest = (composeId: string) => ({
|
|
|
|
type: COMPOSE_UPLOAD_CHANGE_REQUEST,
|
|
|
|
type: COMPOSE_UPLOAD_CHANGE_REQUEST,
|
|
|
|
|
|
|
|
id: composeId,
|
|
|
|
skipLoading: true,
|
|
|
|
skipLoading: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const changeUploadComposeSuccess = (media: APIEntity) => ({
|
|
|
|
const changeUploadComposeSuccess = (composeId: string, media: APIEntity) => ({
|
|
|
|
type: COMPOSE_UPLOAD_CHANGE_SUCCESS,
|
|
|
|
type: COMPOSE_UPLOAD_CHANGE_SUCCESS,
|
|
|
|
|
|
|
|
id: composeId,
|
|
|
|
media: media,
|
|
|
|
media: media,
|
|
|
|
skipLoading: true,
|
|
|
|
skipLoading: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const changeUploadComposeFail = (id: string, error: AxiosError) => ({
|
|
|
|
const changeUploadComposeFail = (composeId: string, id: string, error: AxiosError) => ({
|
|
|
|
type: COMPOSE_UPLOAD_CHANGE_FAIL,
|
|
|
|
type: COMPOSE_UPLOAD_CHANGE_FAIL,
|
|
|
|
|
|
|
|
composeId,
|
|
|
|
id,
|
|
|
|
id,
|
|
|
|
error: error,
|
|
|
|
error: error,
|
|
|
|
skipLoading: true,
|
|
|
|
skipLoading: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const uploadComposeRequest = () => ({
|
|
|
|
const uploadComposeRequest = (composeId: string) => ({
|
|
|
|
type: COMPOSE_UPLOAD_REQUEST,
|
|
|
|
type: COMPOSE_UPLOAD_REQUEST,
|
|
|
|
|
|
|
|
id: composeId,
|
|
|
|
skipLoading: true,
|
|
|
|
skipLoading: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const uploadComposeProgress = (loaded: number, total: number) => ({
|
|
|
|
const uploadComposeProgress = (composeId: string, loaded: number, total: number) => ({
|
|
|
|
type: COMPOSE_UPLOAD_PROGRESS,
|
|
|
|
type: COMPOSE_UPLOAD_PROGRESS,
|
|
|
|
|
|
|
|
id: composeId,
|
|
|
|
loaded: loaded,
|
|
|
|
loaded: loaded,
|
|
|
|
total: total,
|
|
|
|
total: total,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const uploadComposeSuccess = (media: APIEntity, file: File) => ({
|
|
|
|
const uploadComposeSuccess = (composeId: string, media: APIEntity, file: File) => ({
|
|
|
|
type: COMPOSE_UPLOAD_SUCCESS,
|
|
|
|
type: COMPOSE_UPLOAD_SUCCESS,
|
|
|
|
|
|
|
|
id: composeId,
|
|
|
|
media: media,
|
|
|
|
media: media,
|
|
|
|
file,
|
|
|
|
file,
|
|
|
|
skipLoading: true,
|
|
|
|
skipLoading: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const uploadComposeFail = (error: AxiosError | true) => ({
|
|
|
|
const uploadComposeFail = (composeId: string, error: AxiosError | true) => ({
|
|
|
|
type: COMPOSE_UPLOAD_FAIL,
|
|
|
|
type: COMPOSE_UPLOAD_FAIL,
|
|
|
|
|
|
|
|
id: composeId,
|
|
|
|
error: error,
|
|
|
|
error: error,
|
|
|
|
skipLoading: true,
|
|
|
|
skipLoading: true,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const undoUploadCompose = (media_id: string) => ({
|
|
|
|
const undoUploadCompose = (composeId: string, media_id: string) => ({
|
|
|
|
type: COMPOSE_UPLOAD_UNDO,
|
|
|
|
type: COMPOSE_UPLOAD_UNDO,
|
|
|
|
|
|
|
|
id: composeId,
|
|
|
|
media_id: media_id,
|
|
|
|
media_id: media_id,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const clearComposeSuggestions = () => {
|
|
|
|
const clearComposeSuggestions = (composeId: string) => {
|
|
|
|
if (cancelFetchComposeSuggestionsAccounts) {
|
|
|
|
if (cancelFetchComposeSuggestionsAccounts) {
|
|
|
|
cancelFetchComposeSuggestionsAccounts();
|
|
|
|
cancelFetchComposeSuggestionsAccounts();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
type: COMPOSE_SUGGESTIONS_CLEAR,
|
|
|
|
type: COMPOSE_SUGGESTIONS_CLEAR,
|
|
|
|
|
|
|
|
id: composeId,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const fetchComposeSuggestionsAccounts = throttle((dispatch, getState, token) => {
|
|
|
|
const fetchComposeSuggestionsAccounts = throttle((dispatch, getState, composeId, token) => {
|
|
|
|
if (cancelFetchComposeSuggestionsAccounts) {
|
|
|
|
if (cancelFetchComposeSuggestionsAccounts) {
|
|
|
|
cancelFetchComposeSuggestionsAccounts();
|
|
|
|
cancelFetchComposeSuggestionsAccounts(composeId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
api(getState).get('/api/v1/accounts/search', {
|
|
|
|
api(getState).get('/api/v1/accounts/search', {
|
|
|
|
cancelToken: new CancelToken(cancel => {
|
|
|
|
cancelToken: new CancelToken(cancel => {
|
|
|
@ -473,7 +491,7 @@ const fetchComposeSuggestionsAccounts = throttle((dispatch, getState, token) =>
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}).then(response => {
|
|
|
|
}).then(response => {
|
|
|
|
dispatch(importFetchedAccounts(response.data));
|
|
|
|
dispatch(importFetchedAccounts(response.data));
|
|
|
|
dispatch(readyComposeSuggestionsAccounts(token, response.data));
|
|
|
|
dispatch(readyComposeSuggestionsAccounts(composeId, token, response.data));
|
|
|
|
}).catch(error => {
|
|
|
|
}).catch(error => {
|
|
|
|
if (!isCancel(error)) {
|
|
|
|
if (!isCancel(error)) {
|
|
|
|
dispatch(showAlertForError(error));
|
|
|
|
dispatch(showAlertForError(error));
|
|
|
@ -481,46 +499,48 @@ const fetchComposeSuggestionsAccounts = throttle((dispatch, getState, token) =>
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}, 200, { leading: true, trailing: true });
|
|
|
|
}, 200, { leading: true, trailing: true });
|
|
|
|
|
|
|
|
|
|
|
|
const fetchComposeSuggestionsEmojis = (dispatch: AppDispatch, getState: () => RootState, token: string) => {
|
|
|
|
const fetchComposeSuggestionsEmojis = (dispatch: AppDispatch, getState: () => RootState, composeId: string, token: string) => {
|
|
|
|
const results = emojiSearch(token.replace(':', ''), { maxResults: 5 } as any);
|
|
|
|
const results = emojiSearch(token.replace(':', ''), { maxResults: 5 } as any);
|
|
|
|
dispatch(readyComposeSuggestionsEmojis(token, results));
|
|
|
|
dispatch(readyComposeSuggestionsEmojis(composeId, token, results));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const fetchComposeSuggestionsTags = (dispatch: AppDispatch, getState: () => RootState, token: string) => {
|
|
|
|
const fetchComposeSuggestionsTags = (dispatch: AppDispatch, getState: () => RootState, composeId: string, token: string) => {
|
|
|
|
const state = getState();
|
|
|
|
const state = getState();
|
|
|
|
const currentTrends = state.trends.items;
|
|
|
|
const currentTrends = state.trends.items;
|
|
|
|
|
|
|
|
|
|
|
|
dispatch(updateSuggestionTags(token, currentTrends));
|
|
|
|
dispatch(updateSuggestionTags(composeId, token, currentTrends));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const fetchComposeSuggestions = (token: string) =>
|
|
|
|
const fetchComposeSuggestions = (composeId: string, token: string) =>
|
|
|
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
|
|
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
|
|
|
switch (token[0]) {
|
|
|
|
switch (token[0]) {
|
|
|
|
case ':':
|
|
|
|
case ':':
|
|
|
|
fetchComposeSuggestionsEmojis(dispatch, getState, token);
|
|
|
|
fetchComposeSuggestionsEmojis(dispatch, getState, composeId, token);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case '#':
|
|
|
|
case '#':
|
|
|
|
fetchComposeSuggestionsTags(dispatch, getState, token);
|
|
|
|
fetchComposeSuggestionsTags(dispatch, getState, composeId, token);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
fetchComposeSuggestionsAccounts(dispatch, getState, token);
|
|
|
|
fetchComposeSuggestionsAccounts(dispatch, getState, composeId, token);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const readyComposeSuggestionsEmojis = (token: string, emojis: Emoji[]) => ({
|
|
|
|
const readyComposeSuggestionsEmojis = (composeId: string, token: string, emojis: Emoji[]) => ({
|
|
|
|
type: COMPOSE_SUGGESTIONS_READY,
|
|
|
|
type: COMPOSE_SUGGESTIONS_READY,
|
|
|
|
|
|
|
|
id: composeId,
|
|
|
|
token,
|
|
|
|
token,
|
|
|
|
emojis,
|
|
|
|
emojis,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const readyComposeSuggestionsAccounts = (token: string, accounts: APIEntity[]) => ({
|
|
|
|
const readyComposeSuggestionsAccounts = (composeId: string, token: string, accounts: APIEntity[]) => ({
|
|
|
|
type: COMPOSE_SUGGESTIONS_READY,
|
|
|
|
type: COMPOSE_SUGGESTIONS_READY,
|
|
|
|
|
|
|
|
id: composeId,
|
|
|
|
token,
|
|
|
|
token,
|
|
|
|
accounts,
|
|
|
|
accounts,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const selectComposeSuggestion = (position: number, token: string | null, suggestion: AutoSuggestion, path: Array<string | number>) =>
|
|
|
|
const selectComposeSuggestion = (composeId: string, position: number, token: string | null, suggestion: AutoSuggestion, path: Array<string | number>) =>
|
|
|
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
|
|
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
|
|
|
let completion, startPosition;
|
|
|
|
let completion, startPosition;
|
|
|
|
|
|
|
|
|
|
|
@ -539,6 +559,7 @@ const selectComposeSuggestion = (position: number, token: string | null, suggest
|
|
|
|
|
|
|
|
|
|
|
|
dispatch({
|
|
|
|
dispatch({
|
|
|
|
type: COMPOSE_SUGGESTION_SELECT,
|
|
|
|
type: COMPOSE_SUGGESTION_SELECT,
|
|
|
|
|
|
|
|
id: composeId,
|
|
|
|
position: startPosition,
|
|
|
|
position: startPosition,
|
|
|
|
token,
|
|
|
|
token,
|
|
|
|
completion,
|
|
|
|
completion,
|
|
|
@ -546,14 +567,16 @@ const selectComposeSuggestion = (position: number, token: string | null, suggest
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const updateSuggestionTags = (token: string, currentTrends: ImmutableList<Tag>) => ({
|
|
|
|
const updateSuggestionTags = (composeId: string, token: string, currentTrends: ImmutableList<Tag>) => ({
|
|
|
|
type: COMPOSE_SUGGESTION_TAGS_UPDATE,
|
|
|
|
type: COMPOSE_SUGGESTION_TAGS_UPDATE,
|
|
|
|
|
|
|
|
id: composeId,
|
|
|
|
token,
|
|
|
|
token,
|
|
|
|
currentTrends,
|
|
|
|
currentTrends,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const updateTagHistory = (tags: string[]) => ({
|
|
|
|
const updateTagHistory = (composeId: string, tags: string[]) => ({
|
|
|
|
type: COMPOSE_TAG_HISTORY_UPDATE,
|
|
|
|
type: COMPOSE_TAG_HISTORY_UPDATE,
|
|
|
|
|
|
|
|
id: composeId,
|
|
|
|
tags,
|
|
|
|
tags,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -572,7 +595,7 @@ const insertIntoTagHistory = (composeId: string, recognizedTags: APIEntity[], te
|
|
|
|
const newHistory = names.slice(0, 1000);
|
|
|
|
const newHistory = names.slice(0, 1000);
|
|
|
|
|
|
|
|
|
|
|
|
tagHistory.set(me as string, newHistory);
|
|
|
|
tagHistory.set(me as string, newHistory);
|
|
|
|
dispatch(updateTagHistory(newHistory));
|
|
|
|
dispatch(updateTagHistory(composeId, newHistory));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const changeComposeSensitivity = (composeId: string) => ({
|
|
|
|
const changeComposeSensitivity = (composeId: string) => ({
|
|
|
@ -665,29 +688,31 @@ const changePollSettings = (composeId: string, expiresIn?: string | number, isMu
|
|
|
|
|
|
|
|
|
|
|
|
const openComposeWithText = (composeId: string, text = '') =>
|
|
|
|
const openComposeWithText = (composeId: string, text = '') =>
|
|
|
|
(dispatch: AppDispatch) => {
|
|
|
|
(dispatch: AppDispatch) => {
|
|
|
|
dispatch(resetCompose());
|
|
|
|
dispatch(resetCompose(composeId));
|
|
|
|
dispatch(openModal('COMPOSE'));
|
|
|
|
dispatch(openModal('COMPOSE'));
|
|
|
|
dispatch(changeCompose(composeId, text));
|
|
|
|
dispatch(changeCompose(composeId, text));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const addToMentions = (accountId: string) =>
|
|
|
|
const addToMentions = (composeId: string, accountId: string) =>
|
|
|
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
|
|
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
|
|
|
const state = getState();
|
|
|
|
const state = getState();
|
|
|
|
const acct = state.accounts.get(accountId)!.acct;
|
|
|
|
const acct = state.accounts.get(accountId)!.acct;
|
|
|
|
|
|
|
|
|
|
|
|
return dispatch({
|
|
|
|
return dispatch({
|
|
|
|
type: COMPOSE_ADD_TO_MENTIONS,
|
|
|
|
type: COMPOSE_ADD_TO_MENTIONS,
|
|
|
|
|
|
|
|
id: composeId,
|
|
|
|
account: acct,
|
|
|
|
account: acct,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const removeFromMentions = (accountId: string) =>
|
|
|
|
const removeFromMentions = (composeId: string, accountId: string) =>
|
|
|
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
|
|
|
(dispatch: AppDispatch, getState: () => RootState) => {
|
|
|
|
const state = getState();
|
|
|
|
const state = getState();
|
|
|
|
const acct = state.accounts.get(accountId)!.acct;
|
|
|
|
const acct = state.accounts.get(accountId)!.acct;
|
|
|
|
|
|
|
|
|
|
|
|
return dispatch({
|
|
|
|
return dispatch({
|
|
|
|
type: COMPOSE_REMOVE_FROM_MENTIONS,
|
|
|
|
type: COMPOSE_REMOVE_FROM_MENTIONS,
|
|
|
|
|
|
|
|
id: composeId,
|
|
|
|
account: acct,
|
|
|
|
account: acct,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|