From 894ac96be34a064268138273c879dc8a1c22bbf1 Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Sat, 7 Sep 2019 19:44:26 -0400 Subject: [PATCH] try to catch QuotaExceededError --- doc/notes.txt | 1 - src/ui.ts | 13 ++++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/doc/notes.txt b/doc/notes.txt index 31cc8ab5..e4c19516 100644 --- a/doc/notes.txt +++ b/doc/notes.txt @@ -148,7 +148,6 @@ TODO: - allow "include graphics.asm" instead of "include project/graphics.asm" - convert more stuff to Promises - target ES6 -- don't have to include bootstrap-tourist each time? - don't have to include firebase always? - squelch error msgs? - test offline? (if window.firebase) diff --git a/src/ui.ts b/src/ui.ts index 38308da1..a74760c6 100644 --- a/src/ui.ts +++ b/src/ui.ts @@ -118,11 +118,13 @@ function requestPersistPermission() { if (navigator.storage && navigator.storage.persist) { navigator.storage.persist().then(persistent=>{ if (persistent) { - alertInfo("We asked your browser to persist local data, and it said yes."); + alertInfo("Your browser says you have unlimited persistent storage quota for this site. If you got an error while storing something, please try again."); } else { - alertInfo("This browser may not persist local data. Are you in a private window?"); + alertInfo("Your browser says your local files may not be persisted. Are you in a private window?"); } }); + } else { + alertInfo("Your browser doesn't support expanding the persistent storage quota."); } } @@ -1709,7 +1711,12 @@ function installErrorHandler() { 'exFatal': true }); $.get("/error?msg=" + encodeURIComponent(msg), "text"); - alertError(msg); + // storage quota full? (Chrome) try to expand it + if (msg.indexOf("QuotaExceededError") >= 0) { + requestPersistPermission(); + } else { + alertError(msg); + } } _pause(); };