got cron job working

This commit is contained in:
lingdocs 2021-08-23 07:44:19 +04:00
parent 3c70ef12ef
commit 6892f7d90a
1 changed files with 7 additions and 4 deletions

View File

@ -130,7 +130,8 @@ class App extends Component<RouteComponentProps, State> {
ReactGA.pageview(window.location.pathname + window.location.search); ReactGA.pageview(window.location.pathname + window.location.search);
} }
dictionary.initialize().then((r) => { dictionary.initialize().then((r) => {
this.networkCronJob.stop(); this.checkUserCronJob.start();
this.networkCronJob.start();
this.setState({ this.setState({
dictionaryStatus: "ready", dictionaryStatus: "ready",
dictionaryInfo: r.dictionaryInfo, dictionaryInfo: r.dictionaryInfo,
@ -204,6 +205,7 @@ class App extends Component<RouteComponentProps, State> {
public componentWillUnmount() { public componentWillUnmount() {
window.removeEventListener("scroll", this.handleScroll); window.removeEventListener("scroll", this.handleScroll);
this.checkUserCronJob.stop();
this.networkCronJob.stop(); this.networkCronJob.stop();
stopLocalDbs(); stopLocalDbs();
Mousetrap.unbind(["ctrl+down", "ctrl+up", "command+down", "command+up"]); Mousetrap.unbind(["ctrl+down", "ctrl+up", "command+down", "command+up"]);
@ -335,10 +337,11 @@ class App extends Component<RouteComponentProps, State> {
} }
} }
private networkCronJob = new CronJob("* * * * *", () => { private checkUserCronJob = 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");
this.handleLoadUser(); this.handleLoadUser();
})
private networkCronJob = new CronJob("1/5 * * * *", () => {
sendSubmissions(); sendSubmissions();
this.handleDictionaryUpdate(); this.handleDictionaryUpdate();
}); });