From 01b9921b2a43e16adf8879307fc88dce469b095c Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 22 Aug 2018 20:37:11 +0100 Subject: [PATCH] Purge cache in case of an integrity error and show a nicer message. --- src/components/ErrorBoundary.tsx | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/components/ErrorBoundary.tsx b/src/components/ErrorBoundary.tsx index a37ca93..6b224a7 100644 --- a/src/components/ErrorBoundary.tsx +++ b/src/components/ErrorBoundary.tsx @@ -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 ( +
+

Integrity Error

+

+ This probably means you put in the wrong encryption password. +

+

+ Please log out from the menu, refresh the page and try again. +

+
+            {error.message}
+          
+
+ ); + } + + if (error) { return ( );