From af3b2fe53beab32e8b28b009538dd7fc3159c304 Mon Sep 17 00:00:00 2001 From: Zain Date: Sun, 31 Oct 2021 16:33:58 +0530 Subject: [PATCH] Cron implementation 2: Untested --- src/view/App.tsx | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/view/App.tsx b/src/view/App.tsx index ea5e9a9..72f4a31 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -28,20 +28,20 @@ class App extends React.Component { dailys: [], habits: [], } - this.handleChangeTodos = this.handleChangeTodos.bind(this) - this.handleChangeDailys = this.handleChangeDailys.bind(this) - this.handleChangeHabits = this.handleChangeHabits.bind(this) - + this.handleChangeTodos = this.handleChangeTodos.bind(this); + this.handleChangeDailys = this.handleChangeDailys.bind(this); + this.handleChangeHabits = this.handleChangeHabits.bind(this); + this.runCron = this.runCron.bind(this); } - CheckCron(props: any) { - let cronDate = new Date(props.lastCron).getTime(); - let now = new Date().getTime(); - if (now > cronDate + 86400000) { + CheckCron(lastCron: string) { + let cronDate = new Date(lastCron).getDate(); + let now = new Date().getDate(); + if (cronDate < now) { return(
Welcome back! Please check your tasks for the last day and hit continue to get your daily rewards.
- +
); } @@ -51,6 +51,7 @@ class App extends React.Component { }; } runCron() { + console.log("running cron"); makeCronReq(this.username, this.credentials) .then(res => { this.setState({ @@ -143,6 +144,7 @@ class App extends React.Component { } render(){ + let content = this.CheckCron(this.state.user_data.lastCron); if(this.state.error) return(
Loading....
) else if(!this.state.isLoaded) @@ -152,7 +154,7 @@ class App extends React.Component { - + {content} ); }