if backend returns an error, show it in toast

This commit is contained in:
Mary Hipp 2023-05-08 15:11:29 -04:00 committed by psychedelicious
parent 79d49853d2
commit 1809990ed4

View File

@ -22,6 +22,8 @@ import {
} from 'services/thunks/gallery';
import { receivedModels } from 'services/thunks/model';
import { receivedOpenAPISchema } from 'services/thunks/schema';
import { makeToast } from '../../../features/system/hooks/useToastWatcher';
import { addToast } from '../../../features/system/store/systemSlice';
type SetEventListenersArg = {
socket: Socket<ServerToClientEvents, ClientToServerEvents>;
@ -78,6 +80,16 @@ export const setEventListeners = (arg: SetEventListenersArg) => {
}
});
socket.on('connect_error', (error) => {
if (error && error.message) {
dispatch(
addToast(
makeToast({ title: error.message, status: 'error', duration: 10000 })
)
);
}
});
/**
* Disconnect
*/