Skip to content
Snippets Groups Projects
Commit 34b9d27a authored by Bo-Chun Chen's avatar Bo-Chun Chen
Browse files

Unset timer when time go to minus

parent 28f38b8b
No related branches found
No related tags found
2 merge requests!16WIP: Feat React frontend,!3Feat update ui
...@@ -69,10 +69,13 @@ function Main(props) { ...@@ -69,10 +69,13 @@ function Main(props) {
socket.on('created', data => { socket.on('created', data => {
if (DEBUG) console.log('account has been created.') if (DEBUG) console.log('account has been created.')
let sec = 3; let sec = 3;
let myTimer;
(function countdown () { (function countdown () {
setModalTitle("Your account is ready!"); setModalTitle("Your account is ready!");
setModalBody(`Will redirect in ${sec--} seconds.`); setModalBody(`Will redirect in ${sec--} seconds.`);
setTimeout(countdown, 1000); myTimer = setTimeout(countdown, 1000);
if (sec < 0)
clearTimeout(myTimer);
})() })()
setTimeout(() => { setTimeout(() => {
if (DEBUG) console.log('Redirecting to /test') if (DEBUG) console.log('Redirecting to /test')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment