mirror of
https://github.com/lemeow125/StudE-Frontend.git
synced 2024-11-17 06:19:25 +08:00
Prevent registers/logins multiple times when spamming buttons
This commit is contained in:
parent
be21689639
commit
b82b9d332f
2 changed files with 42 additions and 38 deletions
|
@ -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>
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue