From d8f3ae43f572374ebd0a1dd9a82e06eb7da186ce Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Thu, 1 Apr 2021 11:48:10 +1100 Subject: [PATCH] Moved database error to only show local error message --- src/contexts/DatabaseContext.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/contexts/DatabaseContext.js b/src/contexts/DatabaseContext.js index 13b0b29..1a06a65 100644 --- a/src/contexts/DatabaseContext.js +++ b/src/contexts/DatabaseContext.js @@ -15,7 +15,6 @@ export function DatabaseProvider({ children }) { const [database, setDatabase] = useState(); const [databaseStatus, setDatabaseStatus] = useState("loading"); const [databaseError, setDatabaseError] = useState(); - // const [worker] = useState(Comlink.wrap(new DatabaseWorker())) useEffect(() => { // Create a test database and open it to see if indexedDB is enabled @@ -45,13 +44,19 @@ export function DatabaseProvider({ children }) { }; function handleDatabaseError(event) { + event.preventDefault(); if (event.reason?.name === "QuotaExceededError") { - event.preventDefault(); setDatabaseError({ name: event.reason.name, message: "Storage Quota Exceeded Please Clear Space and Try Again.", }); + } else { + setDatabaseError({ + name: event.reason.name, + message: "Something went wrong, please refresh your browser.", + }); } + console.error(event.reason); } window.addEventListener("unhandledrejection", handleDatabaseError);