fix? bug with rerendering breaking game
This commit is contained in:
parent
ace7acc684
commit
35e9d0103b
|
@ -145,8 +145,7 @@ 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.checkUserCronJob.start();
|
this.cronJob.start();
|
||||||
this.networkCronJob.start();
|
|
||||||
this.setState({
|
this.setState({
|
||||||
dictionaryStatus: "ready",
|
dictionaryStatus: "ready",
|
||||||
dictionaryInfo: r.dictionaryInfo,
|
dictionaryInfo: r.dictionaryInfo,
|
||||||
|
@ -231,8 +230,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.cronJob.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"]);
|
||||||
Mousetrap.unbind(["ctrl+b", "command+b"]);
|
Mousetrap.unbind(["ctrl+b", "command+b"]);
|
||||||
|
@ -276,8 +274,10 @@ class App extends Component<RouteComponentProps, State> {
|
||||||
|
|
||||||
private async handleLoadUser(): Promise<void> {
|
private async handleLoadUser(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
|
console.log("getting user");
|
||||||
const prevUser = this.state.user;
|
const prevUser = this.state.user;
|
||||||
const userOnServer = await getUser();
|
const userOnServer = await getUser();
|
||||||
|
console.log({ userOnServer });
|
||||||
if (userOnServer === "offline") return;
|
if (userOnServer === "offline") return;
|
||||||
if (userOnServer) sendSubmissions();
|
if (userOnServer) sendSubmissions();
|
||||||
if (!userOnServer) {
|
if (!userOnServer) {
|
||||||
|
@ -323,10 +323,13 @@ class App extends Component<RouteComponentProps, State> {
|
||||||
dictionary.update(() => {
|
dictionary.update(() => {
|
||||||
this.setState({ dictionaryStatus: "updating" });
|
this.setState({ dictionaryStatus: "updating" });
|
||||||
}).then(({ dictionaryInfo }) => {
|
}).then(({ dictionaryInfo }) => {
|
||||||
this.setState({
|
if (this.state.dictionaryInfo?.release !== dictionaryInfo?.release) {
|
||||||
dictionaryStatus: "ready",
|
// to avoid unnecessary re-rendering that breaks things
|
||||||
dictionaryInfo,
|
this.setState({
|
||||||
});
|
dictionaryStatus: "ready",
|
||||||
|
dictionaryInfo,
|
||||||
|
});
|
||||||
|
}
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.setState({ dictionaryStatus: "error loading" });
|
this.setState({ dictionaryStatus: "error loading" });
|
||||||
});
|
});
|
||||||
|
@ -414,14 +417,11 @@ class App extends Component<RouteComponentProps, State> {
|
||||||
|
|
||||||
// TODO: right now not checking user very often cause it messes with the state?
|
// TODO: right now not checking user very often cause it messes with the state?
|
||||||
// causes the verb quizzer to reset?
|
// causes the verb quizzer to reset?
|
||||||
private checkUserCronJob = new CronJob("1/20 * * * *", () => {
|
private cronJob = new CronJob("* * * * *", () => {
|
||||||
|
this.handleDictionaryUpdate();
|
||||||
this.handleLoadUser();
|
this.handleLoadUser();
|
||||||
})
|
})
|
||||||
|
|
||||||
private networkCronJob = new CronJob("1/5 * * * *", () => {
|
|
||||||
this.handleDictionaryUpdate();
|
|
||||||
});
|
|
||||||
|
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
private handleScroll() {
|
private handleScroll() {
|
||||||
if (hitBottom() && this.props.location.pathname === "/search" && this.state.results.length >= (pageSize * this.state.page)) {
|
if (hitBottom() && this.props.location.pathname === "/search" && this.state.results.length >= (pageSize * this.state.page)) {
|
||||||
|
|
|
@ -102,7 +102,6 @@ function IsolatedEntry({ state, dictionary, isolateEntry }: {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
console.log(inf);
|
|
||||||
return <div className="width-limiter">
|
return <div className="width-limiter">
|
||||||
<Helmet>
|
<Helmet>
|
||||||
<title>{entry.p} - LingDocs Pashto Dictionary</title>
|
<title>{entry.p} - LingDocs Pashto Dictionary</title>
|
||||||
|
|
Loading…
Reference in New Issue