Purge cache in case of an integrity error and show a nicer message.

master
Tom Hacohen 6 years ago
parent 73897700d9
commit 01b9921b2a

@ -1,5 +1,8 @@
import * as React from 'react';
import { persistor } from '../store';
import { IntegrityError } from '../api/EteSync';
import PrettyError from '../widgets/PrettyError';
class ErrorBoundary extends React.Component {
@ -13,11 +16,33 @@ class ErrorBoundary extends React.Component {
}
componentDidCatch(error: Error, info: any) {
if (error instanceof IntegrityError) {
persistor.purge();
}
this.setState({ error });
}
render() {
if (this.state.error) {
const { error } = this.state;
if (error && error instanceof IntegrityError) {
return (
<div>
<h2>Integrity Error</h2>
<p>
This probably means you put in the wrong encryption password.
</p>
<p>
Please log out from the menu, refresh the page and try again.
</p>
<pre>
{error.message}
</pre>
</div>
);
}
if (error) {
return (
<PrettyError error={this.state.error} />
);

Loading…
Cancel
Save