This commit is contained in:
mgabdev
2020-03-14 13:31:29 -04:00
parent d78dd971c0
commit 65af72faae
81 changed files with 1101 additions and 662 deletions

View File

@@ -1,55 +0,0 @@
//test
import { defineMessages } from 'react-intl';
const messages = defineMessages({
unexpectedTitle: { id: 'alert.unexpected.title', defaultMessage: 'Oops!' },
unexpectedMessage: { id: 'alert.unexpected.message', defaultMessage: 'An unexpected error occurred.' },
});
export const ALERT_SHOW = 'ALERT_SHOW';
export const ALERT_DISMISS = 'ALERT_DISMISS';
export const ALERT_CLEAR = 'ALERT_CLEAR';
export function dismissAlert(alert) {
return {
type: ALERT_DISMISS,
alert,
};
};
export function clearAlert() {
return {
type: ALERT_CLEAR,
};
};
export function showAlert(title = messages.unexpectedTitle, message = messages.unexpectedMessage) {
return {
type: ALERT_SHOW,
title,
message,
};
};
export function showAlertForError(error) {
if (error.response) {
const { data, status, statusText } = error.response;
if (status === 404 || status === 410) {
// Skip these errors as they are reflected in the UI
return {};
}
let message = statusText;
let title = `${status}`;
if (data.error) {
message = data.error;
}
return showAlert(title, message);
} else {
console.error(error);
return showAlert();
}
}

View File

@@ -8,8 +8,7 @@ import { useEmoji } from './emojis';
import resizeImage from '../utils/resize_image';
import { importFetchedAccounts } from './importer';
import { updateTimeline, dequeueTimeline } from './timelines';
import { showAlertForError } from './alerts';
import { showAlert } from './alerts';
// import { showAlert, showAlertForError } from './alerts';
import { defineMessages } from 'react-intl';
import { openModal, closeModal } from './modal';
import { me } from '../initial_state';
@@ -134,13 +133,13 @@ export function handleComposeSubmit(dispatch, getState, response, status) {
const isScheduledStatus = response.data['scheduled_at'] !== undefined;
if (isScheduledStatus) {
dispatch(showAlertForError({
response: {
data: {},
status: 200,
statusText: 'Successfully scheduled status',
}
}));
// dispatch(showAlertForError({
// response: {
// data: {},
// status: 200,
// statusText: 'Successfully scheduled status',
// }
// }));
dispatch(submitComposeSuccess({ ...response.data }));
return;
}
@@ -247,12 +246,12 @@ export function uploadCompose(files) {
let total = Array.from(files).reduce((a, v) => a + v.size, 0);
if (files.length + media.size > uploadLimit) {
dispatch(showAlert(undefined, messages.uploadErrorLimit));
// dispatch(showAlert(undefined, messages.uploadErrorLimit));
return;
}
if (getState().getIn(['compose', 'poll'])) {
dispatch(showAlert(undefined, messages.uploadErrorPoll));
// dispatch(showAlert(undefined, messages.uploadErrorPoll));
return;
}
@@ -379,7 +378,7 @@ const fetchComposeSuggestionsAccounts = throttle((dispatch, getState, token) =>
dispatch(readyComposeSuggestionsAccounts(token, response.data));
}).catch(error => {
if (!isCancel(error)) {
dispatch(showAlertForError(error));
// dispatch(showAlertForError(error));
}
});
}, 200, { leading: true, trailing: true });

View File

@@ -1,6 +1,6 @@
import api from '../api';
import { importFetchedAccounts } from './importer';
import { showAlertForError } from './alerts';
// import { showAlertForError } from './alerts';
import { me } from '../initial_state'
export const LIST_FETCH_REQUEST = 'LIST_FETCH_REQUEST';
@@ -263,7 +263,8 @@ export const fetchListSuggestions = q => (dispatch, getState) => {
api(getState).get('/api/v1/accounts/search', { params }).then(({ data }) => {
dispatch(importFetchedAccounts(data));
dispatch(fetchListSuggestionsReady(q, data));
}).catch(error => dispatch(showAlertForError(error)));
})
// }).catch(error => dispatch(showAlertForError(error)));
};
export const fetchListSuggestionsReady = (query, accounts) => ({

View File

@@ -1,6 +1,6 @@
import api from '../api';
import { debounce } from 'lodash';
import { showAlertForError } from './alerts';
// import { showAlertForError } from './alerts';
import { me } from '../initial_state';
export const SETTING_CHANGE = 'SETTING_CHANGE';
@@ -29,7 +29,7 @@ const debouncedSave = debounce((dispatch, getState) => {
api().put('/api/web/settings', { data })
.then(() => dispatch({ type: SETTING_SAVE }))
.catch(error => dispatch(showAlertForError(error)));
// .catch(error => dispatch(showAlertForError(error)));
}, 5000, { trailing: true });
export function saveSettings() {