CronImplementation 3: tested

This commit is contained in:
Zain 2021-11-01 11:41:31 +05:30
parent b3282a360c
commit e0f400b761
No known key found for this signature in database
GPG key ID: 84AD8F072D45C37F

View file

@ -37,7 +37,8 @@ class App extends React.Component<any,any> {
CheckCron(lastCron: string) { CheckCron(lastCron: string) {
let cronDate = new Date(lastCron).getDate(); let cronDate = new Date(lastCron).getDate();
let now = new Date().getDate(); let now = new Date().getDate();
if (cronDate < now) { console.log(cronDate, now);
if (cronDate != now) {
return( return(
<div className="cron"> <div className="cron">
<div id="cronMessage"> Welcome back! Please check your tasks for the last day and hit continue to get your daily rewards. </div> <div id="cronMessage"> Welcome back! Please check your tasks for the last day and hit continue to get your daily rewards. </div>
@ -50,14 +51,17 @@ class App extends React.Component<any,any> {
return null return null
}; };
} }
runCron() { async runCron() {
console.log("running cron"); console.log("running cron");
makeCronReq(this.username, this.credentials) try {
.then(res => { let response = await makeCronReq(this.username, this.credentials);
this.setState({ this.setState({
needCron: false, needCron: false,
}) })
}); } catch (error) {
console.log(error);
new Notice("There was an error running the cron. Please try again later.");
}
this.reloadData(); this.reloadData();
} }
async reloadData() { async reloadData() {