Error boundary: simplify page.

master
Tom Hacohen 4 years ago
parent 1489f8ec1b
commit 14fd5832f5

@ -3,10 +3,7 @@
import * as React from "react"; import * as React from "react";
import { store, persistor } from "../store"; import { IntegrityError } from "etebase";
import { resetKey } from "../store/actions";
import { EncryptionPasswordError, IntegrityError } from "etebase";
import PrettyError from "../widgets/PrettyError"; import PrettyError from "../widgets/PrettyError";
interface PropsType { interface PropsType {
@ -24,28 +21,13 @@ class ErrorBoundary extends React.Component<PropsType> {
} }
public componentDidCatch(error: Error, _info: any) { public componentDidCatch(error: Error, _info: any) {
if (error instanceof EncryptionPasswordError) {
store.dispatch(resetKey());
} else if (error instanceof IntegrityError) {
persistor.purge();
}
this.setState({ error }); this.setState({ error });
} }
public render() { public render() {
const { error } = this.state; const { error } = this.state;
if (error) { if (error) {
if (error instanceof EncryptionPasswordError) { if (error instanceof IntegrityError) {
return (
<div>
<h2>Wrong Encryption Password</h2>
<p>
It looks like you've entered the wrong encryption password, please refresh the page and try again.
</p>
</div>
);
} else if (error instanceof IntegrityError) {
return ( return (
<div> <div>
<h2>Integrity Error</h2> <h2>Integrity Error</h2>

Loading…
Cancel
Save