prevent bugs caused by calling functions out of order

This commit is contained in:
josephsmendoza
2023-07-14 20:15:33 -07:00
parent 7d71419125
commit 907cbea17a
+6
View File
@@ -81,11 +81,17 @@ function add_time(time){
} }
function start(){ function start(){
if(time_started){
return
}
time_started=Date.now() time_started=Date.now()
localforage.setItem('time_started',time_started) localforage.setItem('time_started',time_started)
} }
function pause(){ function pause(){
if(!time_started){
return
}
time_passed+=Date.now()-time_started time_passed+=Date.now()-time_started
time_started=null time_started=null
localforage.removeItem('time_started') localforage.removeItem('time_started')