kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Convert 'error' usage to Toast
rodzic
b7d0b4abe8
commit
b348ca71b9
|
@ -14,7 +14,6 @@ import { createApp } from 'soapbox/actions/apps';
|
|||
import { fetchMeSuccess, fetchMeFail } from 'soapbox/actions/me';
|
||||
import { obtainOAuthToken, revokeOAuthToken } from 'soapbox/actions/oauth';
|
||||
import { startOnboarding } from 'soapbox/actions/onboarding';
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
import { custom } from 'soapbox/custom';
|
||||
import { queryClient } from 'soapbox/queries/client';
|
||||
import KVStore from 'soapbox/storage/kv-store';
|
||||
|
@ -217,7 +216,7 @@ export const logIn = (username: string, password: string) =>
|
|||
throw error;
|
||||
} else {
|
||||
// Return "wrong password" message.
|
||||
dispatch(snackbar.error(messages.invalidCredentials));
|
||||
toast.error(messages.invalidCredentials);
|
||||
}
|
||||
throw error;
|
||||
});
|
||||
|
|
|
@ -3,7 +3,6 @@ import { List as ImmutableList } from 'immutable';
|
|||
import throttle from 'lodash/throttle';
|
||||
import { defineMessages, IntlShape } from 'react-intl';
|
||||
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
import api from 'soapbox/api';
|
||||
import { search as emojiSearch } from 'soapbox/features/emoji/emoji-mart-search-light';
|
||||
import { tagHistory } from 'soapbox/settings';
|
||||
|
@ -249,7 +248,7 @@ const submitCompose = (composeId: string, routerHistory?: History, force = false
|
|||
let to = compose.to;
|
||||
|
||||
if (!validateSchedule(state, composeId)) {
|
||||
dispatch(snackbar.error(messages.scheduleError));
|
||||
toast.error(messages.scheduleError);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -350,18 +349,18 @@ const uploadCompose = (composeId: string, files: FileList, intl: IntlShape) =>
|
|||
if (isImage && maxImageSize && (f.size > maxImageSize)) {
|
||||
const limit = formatBytes(maxImageSize);
|
||||
const message = intl.formatMessage(messages.exceededImageSizeLimit, { limit });
|
||||
dispatch(snackbar.error(message));
|
||||
toast.error(message);
|
||||
dispatch(uploadComposeFail(composeId, true));
|
||||
return;
|
||||
} else if (isVideo && maxVideoSize && (f.size > maxVideoSize)) {
|
||||
const limit = formatBytes(maxVideoSize);
|
||||
const message = intl.formatMessage(messages.exceededVideoSizeLimit, { limit });
|
||||
dispatch(snackbar.error(message));
|
||||
toast.error(message);
|
||||
dispatch(uploadComposeFail(composeId, true));
|
||||
return;
|
||||
} else if (isVideo && maxVideoDuration && (videoDurationInSeconds > maxVideoDuration)) {
|
||||
const message = intl.formatMessage(messages.exceededVideoDurationLimit, { limit: maxVideoDuration });
|
||||
dispatch(snackbar.error(message));
|
||||
toast.error(message);
|
||||
dispatch(uploadComposeFail(composeId, true));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import resizeImage from 'soapbox/utils/resize-image';
|
|||
import { importFetchedAccounts, importFetchedStatus, importFetchedStatuses } from './importer';
|
||||
import { fetchMedia, uploadMedia } from './media';
|
||||
import { closeModal, openModal } from './modals';
|
||||
import snackbar from './snackbar';
|
||||
import {
|
||||
STATUS_FETCH_SOURCE_FAIL,
|
||||
STATUS_FETCH_SOURCE_REQUEST,
|
||||
|
@ -164,7 +163,7 @@ const uploadEventBanner = (file: File, intl: IntlShape) =>
|
|||
if (maxImageSize && (file.size > maxImageSize)) {
|
||||
const limit = formatBytes(maxImageSize);
|
||||
const message = intl.formatMessage(messages.exceededImageSizeLimit, { limit });
|
||||
dispatch(snackbar.error(message));
|
||||
toast.error(message);
|
||||
dispatch(uploadEventBannerFail(true));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ import { initMuteModal } from 'soapbox/actions/mutes';
|
|||
import { initReport } from 'soapbox/actions/reports';
|
||||
import { setSearchAccount } from 'soapbox/actions/search';
|
||||
import { getSettings } from 'soapbox/actions/settings';
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
import Badge from 'soapbox/components/badge';
|
||||
import StillImage from 'soapbox/components/still-image';
|
||||
import { Avatar, HStack, IconButton, Menu, MenuButton, MenuDivider, MenuItem, MenuLink, MenuList } from 'soapbox/components/ui';
|
||||
|
@ -93,7 +92,7 @@ const Header: React.FC<IHeader> = ({ account }) => {
|
|||
}, {
|
||||
onError: (error: AxiosError) => {
|
||||
const data = error.response?.data as any;
|
||||
dispatch(snackbar.error(data?.error));
|
||||
toast.error(data?.error);
|
||||
},
|
||||
onSuccess: (response) => {
|
||||
history.push(`/chats/${response.data.id}`);
|
||||
|
|
|
@ -3,13 +3,13 @@ import { AxiosError } from 'axios';
|
|||
import React, { useState } from 'react';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
import { Icon, Input, Stack } from 'soapbox/components/ui';
|
||||
import { ChatWidgetScreens, useChatContext } from 'soapbox/contexts/chat-context';
|
||||
import { useAppDispatch, useDebounce } from 'soapbox/hooks';
|
||||
import { useDebounce } from 'soapbox/hooks';
|
||||
import { useChats } from 'soapbox/queries/chats';
|
||||
import { queryClient } from 'soapbox/queries/client';
|
||||
import useAccountSearch from 'soapbox/queries/search';
|
||||
import toast from 'soapbox/toast';
|
||||
|
||||
import { ChatKeys } from '../../../../queries/chats';
|
||||
|
||||
|
@ -25,7 +25,6 @@ const ChatSearch = (props: IChatSearch) => {
|
|||
const { isMainPage = false } = props;
|
||||
|
||||
const debounce = useDebounce;
|
||||
const dispatch = useAppDispatch();
|
||||
const history = useHistory();
|
||||
|
||||
const { changeScreen } = useChatContext();
|
||||
|
@ -45,7 +44,7 @@ const ChatSearch = (props: IChatSearch) => {
|
|||
}, {
|
||||
onError: (error: AxiosError) => {
|
||||
const data = error.response?.data as any;
|
||||
dispatch(snackbar.error(data?.error));
|
||||
toast.error(data?.error);
|
||||
},
|
||||
onSuccess: (response) => {
|
||||
if (isMainPage) {
|
||||
|
|
|
@ -2,7 +2,6 @@ import React from 'react';
|
|||
import { defineMessages, useIntl } from 'react-intl';
|
||||
|
||||
import { deleteAccount } from 'soapbox/actions/security';
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
import { Button, Card, CardBody, CardHeader, CardTitle, Form, FormActions, FormGroup, Input, Stack, Text } from 'soapbox/components/ui';
|
||||
import { useAppDispatch, useFeatures } from 'soapbox/hooks';
|
||||
import toast from 'soapbox/toast';
|
||||
|
@ -40,7 +39,7 @@ const DeleteAccount = () => {
|
|||
setLoading(false);
|
||||
}).catch(() => {
|
||||
setPassword('');
|
||||
dispatch(snackbar.error(intl.formatMessage(messages.deleteAccountFail)));
|
||||
toast.error(intl.formatMessage(messages.deleteAccountFail));
|
||||
});
|
||||
}, [password, dispatch, intl]);
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ import { FormattedMessage, defineMessages, useIntl } from 'react-intl';
|
|||
import { useDispatch } from 'react-redux';
|
||||
|
||||
import { changeSettingImmediate } from 'soapbox/actions/settings';
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
import { Column, Button, Form, FormActions, FormGroup, Input, Text } from 'soapbox/components/ui';
|
||||
import toast from 'soapbox/toast';
|
||||
|
||||
|
@ -30,7 +29,7 @@ const DevelopersChallenge = () => {
|
|||
dispatch(changeSettingImmediate(['isDeveloper'], true));
|
||||
toast.success(intl.formatMessage(messages.success));
|
||||
} else {
|
||||
dispatch(snackbar.error(intl.formatMessage(messages.fail)));
|
||||
toast.error(intl.formatMessage(messages.fail));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ import React from 'react';
|
|||
import { defineMessages, useIntl } from 'react-intl';
|
||||
|
||||
import { changeEmail } from 'soapbox/actions/security';
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
import { Button, Card, CardBody, CardHeader, CardTitle, Column, Form, FormActions, FormGroup, Input } from 'soapbox/components/ui';
|
||||
import { useAppDispatch } from 'soapbox/hooks';
|
||||
import toast from 'soapbox/toast';
|
||||
|
@ -44,7 +43,7 @@ const EditEmail = () => {
|
|||
setLoading(false);
|
||||
}).catch(() => {
|
||||
setState((prevState) => ({ ...prevState, password: '' }));
|
||||
dispatch(snackbar.error(intl.formatMessage(messages.updateEmailFail)));
|
||||
toast.error(intl.formatMessage(messages.updateEmailFail));
|
||||
});
|
||||
}, [email, password, dispatch, intl]);
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ import React from 'react';
|
|||
import { defineMessages, useIntl } from 'react-intl';
|
||||
|
||||
import { changePassword } from 'soapbox/actions/security';
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
import { Button, Card, CardBody, CardHeader, CardTitle, Column, Form, FormActions, FormGroup, Input } from 'soapbox/components/ui';
|
||||
import { useAppDispatch, useFeatures } from 'soapbox/hooks';
|
||||
import toast from 'soapbox/toast';
|
||||
|
@ -51,7 +50,7 @@ const EditPassword = () => {
|
|||
setLoading(false);
|
||||
}).catch(() => {
|
||||
resetState();
|
||||
dispatch(snackbar.error(intl.formatMessage(messages.updatePasswordFail)));
|
||||
toast.error(intl.formatMessage(messages.updatePasswordFail));
|
||||
});
|
||||
}, [currentPassword, newPassword, newPasswordConfirmation, dispatch, intl]);
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ import { defineMessages, useIntl, FormattedMessage } from 'react-intl';
|
|||
|
||||
import { updateNotificationSettings } from 'soapbox/actions/accounts';
|
||||
import { patchMe } from 'soapbox/actions/me';
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
import BirthdayInput from 'soapbox/components/birthday-input';
|
||||
import List, { ListItem } from 'soapbox/components/list';
|
||||
import {
|
||||
|
@ -221,7 +220,7 @@ const EditProfile: React.FC = () => {
|
|||
toast.success(intl.formatMessage(messages.success));
|
||||
}).catch(() => {
|
||||
setLoading(false);
|
||||
dispatch(snackbar.error(intl.formatMessage(messages.error)));
|
||||
toast.error(intl.formatMessage(messages.error));
|
||||
});
|
||||
|
||||
event.preventDefault();
|
||||
|
|
|
@ -3,7 +3,6 @@ import { defineMessages, useIntl } from 'react-intl';
|
|||
import { Redirect } from 'react-router-dom';
|
||||
|
||||
import { confirmChangedEmail } from 'soapbox/actions/security';
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
import { Spinner } from 'soapbox/components/ui';
|
||||
import { useAppDispatch } from 'soapbox/hooks';
|
||||
import toast from 'soapbox/toast';
|
||||
|
@ -41,14 +40,12 @@ const EmailConfirmation = () => {
|
|||
if (error.response.data.error) {
|
||||
const message = buildErrorMessage(error.response.data.error);
|
||||
|
||||
dispatch(
|
||||
snackbar.error(
|
||||
message,
|
||||
// intl.formatMessage({
|
||||
// id: 'email_confirmation.fail',
|
||||
// defaultMessage,
|
||||
// }),
|
||||
),
|
||||
toast.error(
|
||||
message,
|
||||
// intl.formatMessage({
|
||||
// id: 'email_confirmation.fail',
|
||||
// defaultMessage,
|
||||
// }),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -2,9 +2,9 @@ import React, { useState, useEffect } from 'react';
|
|||
import { useIntl, FormattedMessage, defineMessages } from 'react-intl';
|
||||
|
||||
import { externalLogin, loginWithCode } from 'soapbox/actions/external-auth';
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
import { Button, Form, FormActions, FormGroup, Input, Spinner } from 'soapbox/components/ui';
|
||||
import { useAppDispatch } from 'soapbox/hooks';
|
||||
import toast from 'soapbox/toast';
|
||||
|
||||
import type { AxiosError } from 'axios';
|
||||
|
||||
|
@ -39,9 +39,9 @@ const ExternalLoginForm: React.FC = () => {
|
|||
const status = error.response?.status;
|
||||
|
||||
if (status) {
|
||||
dispatch(snackbar.error(intl.formatMessage(messages.instanceFailed)));
|
||||
toast.error(intl.formatMessage(messages.instanceFailed));
|
||||
} else if (!status && error.code === 'ERR_NETWORK') {
|
||||
dispatch(snackbar.error(intl.formatMessage(messages.networkFailed)));
|
||||
toast.error(intl.formatMessage(messages.networkFailed));
|
||||
}
|
||||
|
||||
setLoading(false);
|
||||
|
|
|
@ -2,7 +2,6 @@ import React, { useEffect, useState } from 'react';
|
|||
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
||||
|
||||
import { fetchFilters, createFilter, deleteFilter } from 'soapbox/actions/filters';
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
import Icon from 'soapbox/components/icon';
|
||||
import ScrollableList from 'soapbox/components/scrollable-list';
|
||||
import { Button, CardHeader, CardTitle, Column, Form, FormActions, FormGroup, Input, Text } from 'soapbox/components/ui';
|
||||
|
@ -11,6 +10,7 @@ import {
|
|||
Checkbox,
|
||||
} from 'soapbox/features/forms';
|
||||
import { useAppDispatch, useAppSelector } from 'soapbox/hooks';
|
||||
import toast from 'soapbox/toast';
|
||||
|
||||
const messages = defineMessages({
|
||||
heading: { id: 'column.filters', defaultMessage: 'Muted words' },
|
||||
|
@ -81,7 +81,7 @@ const Filters = () => {
|
|||
dispatch(createFilter(phrase, expiresAt, context, wholeWord, irreversible)).then(() => {
|
||||
return dispatch(fetchFilters());
|
||||
}).catch(error => {
|
||||
dispatch(snackbar.error(intl.formatMessage(messages.create_error)));
|
||||
toast.error(intl.formatMessage(messages.create_error));
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -89,7 +89,7 @@ const Filters = () => {
|
|||
dispatch(deleteFilter(e.currentTarget.dataset.value!)).then(() => {
|
||||
return dispatch(fetchFilters());
|
||||
}).catch(() => {
|
||||
dispatch(snackbar.error(intl.formatMessage(messages.delete_error)));
|
||||
toast.error(intl.formatMessage(messages.delete_error));
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
|||
import { Link } from 'react-router-dom';
|
||||
|
||||
import { moveAccount } from 'soapbox/actions/security';
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
import { Button, Column, Form, FormActions, FormGroup, Input, Text } from 'soapbox/components/ui';
|
||||
import { useAppDispatch, useInstance } from 'soapbox/hooks';
|
||||
import toast from 'soapbox/toast';
|
||||
|
@ -53,7 +52,7 @@ const Migration = () => {
|
|||
message = intl.formatMessage(messages.moveAccountFailCooldownPeriod);
|
||||
}
|
||||
|
||||
dispatch(snackbar.error(message));
|
||||
toast.error(message);
|
||||
}).then(() => {
|
||||
setIsLoading(false);
|
||||
});
|
||||
|
|
|
@ -4,9 +4,9 @@ import { defineMessages, FormattedMessage } from 'react-intl';
|
|||
import { useDispatch } from 'react-redux';
|
||||
|
||||
import { patchMe } from 'soapbox/actions/me';
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
import { Avatar, Button, Card, CardBody, Icon, Spinner, Stack, Text } from 'soapbox/components/ui';
|
||||
import { useOwnAccount } from 'soapbox/hooks';
|
||||
import toast from 'soapbox/toast';
|
||||
import { isDefaultAvatar } from 'soapbox/utils/accounts';
|
||||
import resizeImage from 'soapbox/utils/resize-image';
|
||||
|
||||
|
@ -56,9 +56,9 @@ const AvatarSelectionStep = ({ onNext }: { onNext: () => void }) => {
|
|||
setSelectedFile(null);
|
||||
|
||||
if (error.response?.status === 422) {
|
||||
dispatch(snackbar.error((error.response.data as any).error.replace('Validation failed: ', '')));
|
||||
toast.error((error.response.data as any).error.replace('Validation failed: ', ''));
|
||||
} else {
|
||||
dispatch(snackbar.error(messages.error));
|
||||
toast.error(messages.error);
|
||||
}
|
||||
});
|
||||
}).catch(console.error);
|
||||
|
|
|
@ -3,9 +3,9 @@ import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
|||
import { useDispatch } from 'react-redux';
|
||||
|
||||
import { patchMe } from 'soapbox/actions/me';
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
import { Button, Card, CardBody, FormGroup, Stack, Text, Textarea } from 'soapbox/components/ui';
|
||||
import { useOwnAccount } from 'soapbox/hooks';
|
||||
import toast from 'soapbox/toast';
|
||||
|
||||
import type { AxiosError } from 'axios';
|
||||
|
||||
|
@ -38,7 +38,7 @@ const BioStep = ({ onNext }: { onNext: () => void }) => {
|
|||
if (error.response?.status === 422) {
|
||||
setErrors([(error.response.data as any).error.replace('Validation failed: ', '')]);
|
||||
} else {
|
||||
dispatch(snackbar.error(messages.error));
|
||||
toast.error(messages.error);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -4,10 +4,10 @@ import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
|||
import { useDispatch } from 'react-redux';
|
||||
|
||||
import { patchMe } from 'soapbox/actions/me';
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
import StillImage from 'soapbox/components/still-image';
|
||||
import { Avatar, Button, Card, CardBody, Icon, Spinner, Stack, Text } from 'soapbox/components/ui';
|
||||
import { useOwnAccount } from 'soapbox/hooks';
|
||||
import toast from 'soapbox/toast';
|
||||
import { isDefaultHeader } from 'soapbox/utils/accounts';
|
||||
import resizeImage from 'soapbox/utils/resize-image';
|
||||
|
||||
|
@ -59,9 +59,9 @@ const CoverPhotoSelectionStep = ({ onNext }: { onNext: () => void }) => {
|
|||
setSelectedFile(null);
|
||||
|
||||
if (error.response?.status === 422) {
|
||||
dispatch(snackbar.error((error.response.data as any).error.replace('Validation failed: ', '')));
|
||||
toast.error((error.response.data as any).error.replace('Validation failed: ', ''));
|
||||
} else {
|
||||
dispatch(snackbar.error(messages.error));
|
||||
toast.error(messages.error);
|
||||
}
|
||||
});
|
||||
}).catch(console.error);
|
||||
|
|
|
@ -3,9 +3,9 @@ import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
|||
import { useDispatch } from 'react-redux';
|
||||
|
||||
import { patchMe } from 'soapbox/actions/me';
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
import { Button, Card, CardBody, FormGroup, Input, Stack, Text } from 'soapbox/components/ui';
|
||||
import { useOwnAccount } from 'soapbox/hooks';
|
||||
import toast from 'soapbox/toast';
|
||||
|
||||
import type { AxiosError } from 'axios';
|
||||
|
||||
|
@ -49,7 +49,7 @@ const DisplayNameStep = ({ onNext }: { onNext: () => void }) => {
|
|||
if (error.response?.status === 422) {
|
||||
setErrors([(error.response.data as any).error.replace('Validation failed: ', '')]);
|
||||
} else {
|
||||
dispatch(snackbar.error(messages.error));
|
||||
toast.error(messages.error);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -3,7 +3,6 @@ import { useIntl, defineMessages, FormattedMessage } from 'react-intl';
|
|||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
import { disableMfa } from 'soapbox/actions/mfa';
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
import { Button, Form, FormGroup, Input, FormActions, Stack, Text } from 'soapbox/components/ui';
|
||||
import { useAppDispatch } from 'soapbox/hooks';
|
||||
import toast from 'soapbox/toast';
|
||||
|
@ -31,7 +30,7 @@ const DisableOtpForm: React.FC = () => {
|
|||
}).finally(() => {
|
||||
setIsLoading(false);
|
||||
}).catch(() => {
|
||||
dispatch(snackbar.error(intl.formatMessage(messages.disableFail)));
|
||||
toast.error(intl.formatMessage(messages.disableFail));
|
||||
});
|
||||
}, [password, dispatch, intl]);
|
||||
|
||||
|
|
|
@ -3,9 +3,9 @@ import { useIntl, defineMessages, FormattedMessage } from 'react-intl';
|
|||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
import { fetchBackupCodes } from 'soapbox/actions/mfa';
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
import { Button, FormActions, Spinner, Stack, Text } from 'soapbox/components/ui';
|
||||
import { useAppDispatch } from 'soapbox/hooks';
|
||||
import toast from 'soapbox/toast';
|
||||
|
||||
const messages = defineMessages({
|
||||
mfaCancelButton: { id: 'column.mfa_cancel', defaultMessage: 'Cancel' },
|
||||
|
@ -30,7 +30,7 @@ const EnableOtpForm: React.FC<IEnableOtpForm> = ({ displayOtpForm, handleSetupPr
|
|||
setBackupCodes(backupCodes);
|
||||
})
|
||||
.catch(() => {
|
||||
dispatch(snackbar.error(intl.formatMessage(messages.codesFail)));
|
||||
toast.error(intl.formatMessage(messages.codesFail));
|
||||
});
|
||||
}, []);
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import {
|
|||
setupMfa,
|
||||
confirmMfa,
|
||||
} from 'soapbox/actions/mfa';
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
import { Button, Form, FormActions, FormGroup, Input, Stack, Text } from 'soapbox/components/ui';
|
||||
import { useAppDispatch } from 'soapbox/hooks';
|
||||
import toast from 'soapbox/toast';
|
||||
|
@ -39,7 +38,7 @@ const OtpConfirmForm: React.FC = () => {
|
|||
dispatch(setupMfa('totp')).then((data: any) => {
|
||||
setState((prevState) => ({ ...prevState, qrCodeURI: data.provisioning_uri, confirmKey: data.key }));
|
||||
}).catch(() => {
|
||||
dispatch(snackbar.error(intl.formatMessage(messages.qrFail)));
|
||||
toast.error(intl.formatMessage(messages.qrFail));
|
||||
});
|
||||
}, []);
|
||||
|
||||
|
@ -56,7 +55,7 @@ const OtpConfirmForm: React.FC = () => {
|
|||
toast.success(intl.formatMessage(messages.mfaConfirmSuccess));
|
||||
history.push('../auth/edit');
|
||||
}).catch(() => {
|
||||
dispatch(snackbar.error(intl.formatMessage(messages.confirmFail)));
|
||||
toast.error(intl.formatMessage(messages.confirmFail));
|
||||
setState((prevState) => ({ ...prevState, isLoading: false }));
|
||||
});
|
||||
|
||||
|
|
|
@ -3,9 +3,9 @@ import { defineMessages, useIntl, FormattedMessage } from 'react-intl';
|
|||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
import { remoteInteraction } from 'soapbox/actions/interactions';
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
import { Button, Modal, Stack, Text } from 'soapbox/components/ui';
|
||||
import { useAppSelector, useAppDispatch, useFeatures, useSoapboxConfig, useInstance } from 'soapbox/hooks';
|
||||
import toast from 'soapbox/toast';
|
||||
|
||||
const messages = defineMessages({
|
||||
close: { id: 'lightbox.close', defaultMessage: 'Close' },
|
||||
|
@ -55,7 +55,7 @@ const UnauthorizedModal: React.FC<IUnauthorizedModal> = ({ action, onClose, acco
|
|||
})
|
||||
.catch(error => {
|
||||
if (error.message === 'Couldn\'t find user') {
|
||||
dispatch(snackbar.error(intl.formatMessage(messages.userNotFoundError)));
|
||||
toast.error(intl.formatMessage(messages.userNotFoundError));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -4,7 +4,6 @@ import OtpInput from 'react-otp-input';
|
|||
|
||||
import { verifyCredentials } from 'soapbox/actions/auth';
|
||||
import { closeModal } from 'soapbox/actions/modals';
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
import { reConfirmPhoneVerification, reRequestPhoneVerification } from 'soapbox/actions/verification';
|
||||
import { FormGroup, PhoneInput, Modal, Stack, Text } from 'soapbox/components/ui';
|
||||
import { useAppDispatch, useAppSelector, useInstance } from 'soapbox/hooks';
|
||||
|
@ -77,11 +76,7 @@ const VerifySmsModal: React.FC<IVerifySmsModal> = ({ onClose }) => {
|
|||
|
||||
if (!isValid) {
|
||||
setStatus(Statuses.IDLE);
|
||||
dispatch(
|
||||
snackbar.error(
|
||||
intl.formatMessage(messages.verificationInvalid),
|
||||
),
|
||||
);
|
||||
toast.error(intl.formatMessage(messages.verificationInvalid));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -92,11 +87,7 @@ const VerifySmsModal: React.FC<IVerifySmsModal> = ({ onClose }) => {
|
|||
})
|
||||
.finally(() => setStatus(Statuses.REQUESTED))
|
||||
.catch(() => {
|
||||
dispatch(
|
||||
snackbar.error(
|
||||
intl.formatMessage(messages.verificationFail),
|
||||
),
|
||||
);
|
||||
toast.error(intl.formatMessage(messages.verificationFail));
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -195,11 +186,7 @@ const VerifySmsModal: React.FC<IVerifySmsModal> = ({ onClose }) => {
|
|||
.then(() => dispatch(closeModal('VERIFY_SMS')));
|
||||
|
||||
})
|
||||
.catch(() => dispatch(
|
||||
snackbar.error(
|
||||
intl.formatMessage(messages.verificationExpired),
|
||||
),
|
||||
));
|
||||
.catch(() => toast.error(intl.formatMessage(messages.verificationExpired)));
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
@ -6,7 +6,6 @@ import {
|
|||
subscribeAccount,
|
||||
unsubscribeAccount,
|
||||
} from 'soapbox/actions/accounts';
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
import { IconButton } from 'soapbox/components/ui';
|
||||
import { useAppDispatch, useFeatures } from 'soapbox/hooks';
|
||||
import toast from 'soapbox/toast';
|
||||
|
@ -44,13 +43,13 @@ const SubscriptionButton = ({ account }: ISubscriptionButton) => {
|
|||
toast.success(intl.formatMessage(messages.subscribeSuccess));
|
||||
|
||||
const onSubscribeFailure = () =>
|
||||
dispatch(snackbar.error(intl.formatMessage(messages.subscribeFailure)));
|
||||
toast.error(intl.formatMessage(messages.subscribeFailure));
|
||||
|
||||
const onUnsubscribeSuccess = () =>
|
||||
toast.success(intl.formatMessage(messages.unsubscribeSuccess));
|
||||
|
||||
const onUnsubscribeFailure = () =>
|
||||
dispatch(snackbar.error(intl.formatMessage(messages.unsubscribeFailure)));
|
||||
toast.error(intl.formatMessage(messages.unsubscribeFailure));
|
||||
|
||||
const onNotifyToggle = () => {
|
||||
if (account.relationship?.notifying) {
|
||||
|
|
|
@ -2,7 +2,6 @@ import React from 'react';
|
|||
import { defineMessages, useIntl } from 'react-intl';
|
||||
import { useHistory, useParams } from 'react-router-dom';
|
||||
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
import { confirmEmailVerification } from 'soapbox/actions/verification';
|
||||
import { Icon, Spinner, Stack, Text } from 'soapbox/components/ui';
|
||||
import { useAppDispatch, useAppSelector } from 'soapbox/hooks';
|
||||
|
@ -145,7 +144,7 @@ const EmailPassThru = () => {
|
|||
}
|
||||
}
|
||||
|
||||
dispatch(snackbar.error(message));
|
||||
toast.error(message);
|
||||
});
|
||||
}
|
||||
}, [token]);
|
||||
|
|
|
@ -5,7 +5,6 @@ import { Redirect } from 'react-router-dom';
|
|||
import { logIn, verifyCredentials } from 'soapbox/actions/auth';
|
||||
import { fetchInstance } from 'soapbox/actions/instance';
|
||||
import { startOnboarding } from 'soapbox/actions/onboarding';
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
import { createAccount, removeStoredVerification } from 'soapbox/actions/verification';
|
||||
import { Button, Form, FormGroup, Input, Text } from 'soapbox/components/ui';
|
||||
import { useAppDispatch, useAppSelector, useInstance, useSoapboxConfig } from 'soapbox/hooks';
|
||||
|
@ -61,17 +60,9 @@ const Registration = () => {
|
|||
})
|
||||
.catch((error: AxiosError) => {
|
||||
if (error?.response?.status === 422) {
|
||||
dispatch(
|
||||
snackbar.error(
|
||||
intl.formatMessage(messages.usernameTaken),
|
||||
),
|
||||
);
|
||||
toast.error(intl.formatMessage(messages.usernameTaken));
|
||||
} else {
|
||||
dispatch(
|
||||
snackbar.error(
|
||||
intl.formatMessage(messages.error),
|
||||
),
|
||||
);
|
||||
toast.error(intl.formatMessage(messages.error));
|
||||
}
|
||||
});
|
||||
}, [username, password]);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import React from 'react';
|
||||
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
||||
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
import { verifyAge } from 'soapbox/actions/verification';
|
||||
import { Button, Datepicker, Form, Text } from 'soapbox/components/ui';
|
||||
import { useAppDispatch, useAppSelector, useInstance } from 'soapbox/hooks';
|
||||
import toast from 'soapbox/toast';
|
||||
|
||||
const messages = defineMessages({
|
||||
fail: {
|
||||
|
@ -42,9 +42,7 @@ const AgeVerification = () => {
|
|||
if (meetsAgeMinimum(birthday, ageMinimum)) {
|
||||
dispatch(verifyAge(birthday));
|
||||
} else {
|
||||
dispatch(
|
||||
snackbar.error(intl.formatMessage(messages.fail, { ageMinimum })),
|
||||
);
|
||||
toast.error(intl.formatMessage(messages.fail, { ageMinimum }));
|
||||
}
|
||||
}, [date, ageMinimum]);
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue