Added persistent storage permissions when uploading maps or tokens
This commit is contained in:
parent
951c515334
commit
926f05f301
@ -91,6 +91,11 @@ function SelectMapModal({
|
||||
const [imageLoading, setImageLoading] = useState(false);
|
||||
|
||||
async function handleImagesUpload(files) {
|
||||
if (navigator.storage) {
|
||||
// Attempt to enable persistant storage
|
||||
await navigator.storage.persist();
|
||||
}
|
||||
|
||||
for (let file of files) {
|
||||
await handleImageUpload(file);
|
||||
}
|
||||
|
@ -70,6 +70,11 @@ function SelectTokensModal({ isOpen, onRequestClose }) {
|
||||
}
|
||||
|
||||
async function handleImagesUpload(files) {
|
||||
if (navigator.storage) {
|
||||
// Attempt to enable persistant storage
|
||||
await navigator.storage.persist();
|
||||
}
|
||||
|
||||
for (let file of files) {
|
||||
await handleImageUpload(file);
|
||||
}
|
||||
|
@ -28,8 +28,21 @@ function SettingsModal({ isOpen, onRequestClose }) {
|
||||
const [storageEstimate, setStorageEstimate] = useState();
|
||||
|
||||
useEffect(() => {
|
||||
async function estimateStorage() {
|
||||
// Persisted data on firefox doesn't count towards the usage quota so ignore it
|
||||
const persisted = await navigator.storage.persisted();
|
||||
const isFirefox =
|
||||
navigator.userAgent.toLowerCase().indexOf("firefox") > -1;
|
||||
if (persisted && isFirefox) {
|
||||
return;
|
||||
}
|
||||
|
||||
const estimate = await navigator.storage.estimate();
|
||||
setStorageEstimate(estimate);
|
||||
}
|
||||
|
||||
if (isOpen && navigator.storage) {
|
||||
navigator.storage.estimate().then(setStorageEstimate);
|
||||
estimateStorage();
|
||||
}
|
||||
}, [isOpen]);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user