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() {
|
export default function Login() {
|
||||||
const navigation = useNavigation<RootDrawerParamList>();
|
const navigation = useNavigation<RootDrawerParamList>();
|
||||||
const status = useSelector((state: RootState) => state.status);
|
const status = useSelector((state: RootState) => state.status);
|
||||||
|
const [logging_in, setLoggingIn] = useState(false);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const [creds, setCreds] = useState({
|
const [creds, setCreds] = useState({
|
||||||
username: "",
|
username: "",
|
||||||
|
@ -76,6 +77,7 @@ export default function Login() {
|
||||||
<View style={{ paddingVertical: 4 }} />
|
<View style={{ paddingVertical: 4 }} />
|
||||||
<Button
|
<Button
|
||||||
onPress={async () => {
|
onPress={async () => {
|
||||||
|
if (logging_in) {
|
||||||
await UserLogin({
|
await UserLogin({
|
||||||
username: creds.username,
|
username: creds.username,
|
||||||
password: creds.password,
|
password: creds.password,
|
||||||
|
@ -118,7 +120,9 @@ export default function Login() {
|
||||||
animationType: "slide-in",
|
animationType: "slide-in",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
setLoggingIn(false);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Text style={styles.text_white_small}>Login</Text>
|
<Text style={styles.text_white_small}>Login</Text>
|
||||||
|
|
|
@ -170,7 +170,6 @@ export default function Register() {
|
||||||
animationType: "slide-in",
|
animationType: "slide-in",
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
setRegistering(false);
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
navigation.navigate("Login");
|
navigation.navigate("Login");
|
||||||
}, 10000);
|
}, 10000);
|
||||||
|
@ -182,6 +181,7 @@ export default function Register() {
|
||||||
animationType: "slide-in",
|
animationType: "slide-in",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
setRegistering(false);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
toast.show(
|
toast.show(
|
||||||
|
|
Loading…
Reference in a new issue