mirror of
https://github.com/mastodon/mastodon.git
synced 2026-09-12 00:56:22 -05:00
adds isLoading to translation state
This commit is contained in:
@@ -29,6 +29,7 @@ const meta = {
|
||||
spoilerHtml: '',
|
||||
language: args.translatedTo,
|
||||
detected_source_language: 'en',
|
||||
isLoading: false,
|
||||
} satisfies StatusTranslation;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ class TranslateButton extends PureComponent {
|
||||
render () {
|
||||
const { translation, onClick } = this.props;
|
||||
|
||||
if (translation) {
|
||||
if (translation && !translation.get('isLoading')) {
|
||||
const language = preloadedLanguages.find(lang => lang[0] === translation.get('detected_source_language'));
|
||||
const languageName = language ? language[1] : translation.get('detected_source_language');
|
||||
const provider = translation.get('provider');
|
||||
|
||||
@@ -156,4 +156,6 @@ export type FilterResult = Omit<ApiFilterResultJSON, 'filter'> & {
|
||||
filter: string;
|
||||
};
|
||||
|
||||
export type StatusTranslation = Omit<ApiStatusTranslationJSON, 'poll'>;
|
||||
export type StatusTranslation = Omit<ApiStatusTranslationJSON, 'poll'> & {
|
||||
isLoading: boolean;
|
||||
};
|
||||
|
||||
@@ -24,6 +24,7 @@ import {
|
||||
STATUS_REVEAL,
|
||||
STATUS_HIDE,
|
||||
STATUS_COLLAPSE,
|
||||
STATUS_TRANSLATE_REQUEST,
|
||||
STATUS_TRANSLATE_SUCCESS,
|
||||
STATUS_TRANSLATE_UNDO,
|
||||
STATUS_FETCH_REQUEST,
|
||||
@@ -46,7 +47,7 @@ const deleteStatus = (state, id, references) => {
|
||||
|
||||
const statusTranslateSuccess = (state, id, translation) => {
|
||||
return state.withMutations(map => {
|
||||
map.setIn([id, 'translation'], fromJS(normalizeStatusTranslation(translation, map.get(id))));
|
||||
map.setIn([id, 'translation'], fromJS(normalizeStatusTranslation(translation, map.get(id))).set('isLoading', false));
|
||||
|
||||
const list = map.getIn([id, 'media_attachments']);
|
||||
if (translation.media_attachments && list) {
|
||||
@@ -146,6 +147,8 @@ export default function statuses(state = initialState, action) {
|
||||
return state.setIn([action.id, 'collapsed'], action.isCollapsed);
|
||||
case timelineDelete.type:
|
||||
return deleteStatus(state, action.payload.statusId, action.payload.references);
|
||||
case STATUS_TRANSLATE_REQUEST:
|
||||
return state.setIn([action.id, 'translation', 'isLoading'], true);
|
||||
case STATUS_TRANSLATE_SUCCESS:
|
||||
return statusTranslateSuccess(state, action.id, action.translation);
|
||||
case STATUS_TRANSLATE_UNDO:
|
||||
|
||||
Reference in New Issue
Block a user