@ -1,8 +1,9 @@
import * as React from 'react' ;
import * as React from 'react' ;
import { persistor } from '../store' ;
import { store , persistor } from '../store' ;
import { resetKey } from '../store/actions' ;
import { IntegrityError } from '../api/EteSync' ;
import { EncryptionPasswordError, IntegrityError } from '../api/EteSync' ;
import PrettyError from '../widgets/PrettyError' ;
import PrettyError from '../widgets/PrettyError' ;
class ErrorBoundary extends React . Component {
class ErrorBoundary extends React . Component {
@ -16,7 +17,9 @@ class ErrorBoundary extends React.Component {
}
}
public componentDidCatch ( error : Error , info : any ) {
public componentDidCatch ( error : Error , info : any ) {
if ( error instanceof IntegrityError ) {
if ( error instanceof EncryptionPasswordError ) {
store . dispatch ( resetKey ( ) ) ;
} else if ( error instanceof IntegrityError ) {
persistor . purge ( ) ;
persistor . purge ( ) ;
}
}
@ -25,15 +28,22 @@ class ErrorBoundary extends React.Component {
public render() {
public render() {
const { error } = this . state ;
const { error } = this . state ;
if ( error && error instanceof IntegrityError ) {
if ( error ) {
if ( error instanceof EncryptionPasswordError ) {
return (
return (
< div >
< div >
< h2 > Integrity Error < / h2 >
< h2 > Wrong Encryption Password < / h2 >
< p >
< p >
This probably means you put in the wrong encryption password .
It looks like you ' ve entered the wrong encryption password , please refresh the page and try again .
< / p >
< / p >
< / div >
) ;
} else if ( error instanceof IntegrityError ) {
return (
< div >
< h2 > Integrity Error < / h2 >
< p >
< p >
Please log out from the menu , refresh the page and try again .
Please log out from the menu , refresh the page and try again , and if the problem persists , contact support .
< / p >
< / p >
< pre >
< pre >
{ error . message }
{ error . message }
@ -41,6 +51,7 @@ class ErrorBoundary extends React.Component {
< / div >
< / div >
) ;
) ;
}
}
}
if ( error ) {
if ( error ) {
return (
return (