Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.catch((err) => {
this.setState({
saved: false,
error: true,
errorMessage: err.message
});
toastr.error('Error', err); // eslint-disable-line no-console
})
.then(() => this.setState({ loading: false }));
function* start({guid}) {
try {
let settings: SettingsState = yield select((state: any) => state.settings);
yield call(startApp, settings.activeInstance, guid);
toastr.success('Alert', 'App started successfully');
} catch (e) {
console.log(e);
toastr.success('Error', 'Unable to start app');
}
}
function* stop({guid}) {
try {
let settings: SettingsState = yield select((state: any) => state.settings);
yield call(stopApp, settings.activeInstance, guid);
toastr.success('Alert', 'App stopped successfully');
} catch (e) {
console.log(e);
toastr.success('Error', 'Unable to stop app');
}
}
function* start({guid}) {
try {
let settings: SettingsState = yield select((state: any) => state.settings);
yield call(startApp, settings.activeInstance, guid);
toastr.success('Alert', 'App started successfully');
} catch (e) {
console.log(e);
toastr.success('Error', 'Unable to start app');
}
}
watchGame(event, game) {
event.preventDefault();
if(!this.props.username) {
toastr.error('Please login before trying to watch a game');
return;
}
if(game.needsPassword) {
this.props.joinPasswordGame(game, 'Watch');
} else {
this.props.socket.emit('watchgame', game.id);
}
}
watchGame(event, game) {
let t = this.props.t;
event.preventDefault();
if(!this.props.user) {
toastr.error(t('Please login before trying to watch a game'));
return;
}
if(game.needsPassword) {
this.props.joinPasswordGame(game, 'Watch');
} else {
this.props.socket.emit('watchgame', game.id);
}
}
export const socketIoMiddleware = store => next => action => {
const result = next(action);
if (action.type === 'CONNECT_SOCKET') {
createSocket(store, (action.payload ?
action.payload.coreURL : store.getState().setting.coreURL
));
}
if (!socket) {
toastr.warning('websocket', "socket doesn't inital");
return result;
}
if (SendActions.indexOf(action.type) > -1) {
if (!socket.connected && action.type !== 'SETTING_CONTROLLER') {
toastr.warning('websocket', 'Not connected');
return result;
}
socket.emit(action.type, {
data: action.payload,
});
}
return result;
};
onError: (error) => {
this.setState({ message: `Error loading insights: ${error}`, loading: false });
toastr.error('Error', error);
}
}
onError: (error) => {
this.setState({ loading: false });
toastr.error('Error', error);
}
});
.catch((err) => {
this.setState({ loading: false });
toastr.error('Error', err);
});
}