Moved database error to only show local error message

This commit is contained in:
Mitchell McCaffrey 2021-04-01 11:48:10 +11:00
parent 24870666fb
commit d8f3ae43f5

View File

@ -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) {
if (event.reason?.name === "QuotaExceededError") {
event.preventDefault();
if (event.reason?.name === "QuotaExceededError") {
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);