From 6892f7d90ae3a1c05a56eb45942d577a6450c083 Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Mon, 23 Aug 2021 07:44:19 +0400 Subject: [PATCH] got cron job working --- website/src/App.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/website/src/App.tsx b/website/src/App.tsx index 1145e0f..6261e48 100644 --- a/website/src/App.tsx +++ b/website/src/App.tsx @@ -130,7 +130,8 @@ class App extends Component { ReactGA.pageview(window.location.pathname + window.location.search); } dictionary.initialize().then((r) => { - this.networkCronJob.stop(); + this.checkUserCronJob.start(); + this.networkCronJob.start(); this.setState({ dictionaryStatus: "ready", dictionaryInfo: r.dictionaryInfo, @@ -204,6 +205,7 @@ class App extends Component { public componentWillUnmount() { window.removeEventListener("scroll", this.handleScroll); + this.checkUserCronJob.stop(); this.networkCronJob.stop(); stopLocalDbs(); Mousetrap.unbind(["ctrl+down", "ctrl+up", "command+down", "command+up"]); @@ -335,10 +337,11 @@ class App extends Component { } } - private networkCronJob = new CronJob("* * * * *", () => { - // TODO: check for new dictionary (in a seperate cron job - not dependant on the user being signed in)\ - console.log("cron job running"); + private checkUserCronJob = new CronJob("* * * * *", () => { this.handleLoadUser(); + }) + + private networkCronJob = new CronJob("1/5 * * * *", () => { sendSubmissions(); this.handleDictionaryUpdate(); });