Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async populateMap(newEvent) {
try {
await this.props.getEvents();
if (this.props.errors.event) throw this.props.errors.event;
if (newEvent) this.focusMarker(newEvent);
Toast.show({
buttonText: "OK",
text: "Events fetched successfully.",
type: "success"
});
} catch (error) {
console.log("Error rendering map: ", error);
Toast.show({
buttonText: "OK",
text: "Error rendering map.",
type: "danger"
});
}
}
createRoom() {
let navigate = this.props.navigation.navigate;
if (this.state.name) {
const roomName = this.state.name;
const playerName = this.props.navigation.state.params.playerName;
socket.emit(CREATE_ROOM, roomName, playerName);
this.setState({ name: '' });
navigate('Lobby', { room: this.state.name, playerName });
} else {
Toast.show({
text: 'Please Enter Room Name!',
buttonText: 'Okay'
});
}
}
handleChange(text) {
createRoom() {
if (this.state.name) {
this.props.navigation.state.params.socket.emit(
'createRoom',
this.state.name
);
Toast.show({
text: 'Room Created!',
position: 'top',
buttonText: 'Okay'
});
} else {
Toast.show({
text: 'Please Enter Room Name!',
buttonText: 'Okay'
});
}
}
handleChange(text) {
}
const response = await userServices.put(data);
if (response instanceof Error) throw response;
const loginResponse = await authServices.login({
username: response.data.email,
password: values.newPassword2
});
if (loginResponse instanceof Error) throw new Error("Error logging in with new password.");
asyncStore.save("user", JSON.stringify(loginResponse));
this.clearForm(resetForm);
this.props.navigation.navigate("SettingsPage", {
refresh: true
});
Toast.show({
buttonText: "OK",
text: "Password change successful.",
type: "success"
});
} catch (error) {
Toast.show({
buttonText: "OK",
text: "Error changing password: " + (error.message || error),
type: "danger"
});
}
};
login() {
if (this.props.valid) {
this.props.navigation.navigate("Drawer");
} else {
Toast.show({
text: "Enter Valid Username & password!",
duration: 2000,
position: "top",
textStyle: { textAlign: "center" },
});
}
}
fetchAdvs = async () => {
try {
const res = await advService.all()
const advs = res.data.data
this.setState({
advs: advs
})
} catch(err) {
Toast.show({
text: '网络异常',
position: 'top',
type: 'danger'
})
}
}
login() {
this.props.loginForm.validateForm();
if (this.props.loginForm.isValid) {
this.props.loginForm.clearStore();
this.props.navigation.navigate("Drawer");
} else {
Toast.show({
text: "Enter Valid Email & password!",
duration: 2000,
position: "top",
textStyle: { textAlign: "center" },
});
}
}
render() {
.catch((error) => {
this.setState({ commentText: '' });
Toast.show({
text: strings(Strings.COMMENT_FAILED),
textStyle: { textAlign: 'center' },
position: 'bottom',
type: 'danger',
});
});
}