Better handling of unsupported INIs, closes: #873

This commit is contained in:
Piotr Rogowski 2022-11-02 20:58:01 +01:00
parent 90b88db1c7
commit 16851ffb5e
No known key found for this signature in database
GPG Key ID: 4A842D702D9C6F8F
2 changed files with 11 additions and 2 deletions

View File

@ -40,6 +40,7 @@ import standardDialogs from './data/standardDialogs';
import help from './data/help';
import {
iniLoadingError,
tuneNotFound,
tuneParsingError,
} from './pages/auth/notifications';
import { divider } from './data/constants';
@ -120,7 +121,9 @@ const App = ({ ui, tuneData }: { ui: UIState, tuneData: TuneDataState }) => {
store.dispatch({ type: 'tune/load', payload: tune });
} catch (error) {
iniLoadingError((error as Error));
navigate(Routes.HUB);
navigate(generatePath(Routes.TUNE_ROOT, {
tuneId: tuneId!,
}));
}
};
@ -149,7 +152,7 @@ const App = ({ ui, tuneData }: { ui: UIState, tuneData: TuneDataState }) => {
getTune(tuneId).then(async (tune) => {
if (!tune) {
console.warn('Tune not found');
tuneNotFound();
navigate(Routes.HUB);
return;
}

View File

@ -125,6 +125,11 @@ const iniLoadingError = (err: Error) => notification.error({
...baseOptions,
});
const tuneNotFound = () => notification.warning({
message: 'Tune not found',
...baseOptions,
});
const tuneParsingError = () => notification.error({
message: 'Tune file is not valid',
...baseOptions,
@ -169,6 +174,7 @@ export {
databaseGenericError,
copiedToClipboard,
iniLoadingError,
tuneNotFound,
tuneParsingError,
signatureNotSupportedWarning,
downloading,