Prevent registers/logins multiple times when spamming buttons

This commit is contained in:
Keannu Bernasol 2023-10-15 11:56:39 +08:00
parent be21689639
commit b82b9d332f
2 changed files with 42 additions and 38 deletions

View file

@ -27,6 +27,7 @@ import { RootState } from "../../features/redux/Store/Store";
export default function Login() {
const navigation = useNavigation<RootDrawerParamList>();
const status = useSelector((state: RootState) => state.status);
const [logging_in, setLoggingIn] = useState(false);
const dispatch = useDispatch();
const [creds, setCreds] = useState({
username: "",
@ -76,6 +77,7 @@ export default function Login() {
<View style={{ paddingVertical: 4 }} />
<Button
onPress={async () => {
if (logging_in) {
await UserLogin({
username: creds.username,
password: creds.password,
@ -118,7 +120,9 @@ export default function Login() {
animationType: "slide-in",
});
}
setLoggingIn(false);
});
}
}}
>
<Text style={styles.text_white_small}>Login</Text>

View file

@ -170,7 +170,6 @@ export default function Register() {
animationType: "slide-in",
}
);
setRegistering(false);
setTimeout(() => {
navigation.navigate("Login");
}, 10000);
@ -182,6 +181,7 @@ export default function Register() {
animationType: "slide-in",
});
}
setRegistering(false);
});
} else {
toast.show(