Fix file import button

This commit is contained in:
Mitchell McCaffrey 2021-04-15 16:28:39 +10:00
parent 47d18e9095
commit 33f34fb54f
2 changed files with 22 additions and 10 deletions

View File

@ -120,11 +120,6 @@ function SelectMapModal({
await navigator.storage.persist();
}
// Set file input to null to allow adding the same image 2 times in a row
if (fileInputRef.current) {
fileInputRef.current.value = null;
}
let mapFiles = [];
for (let file of files) {
if (file.size > 5e7) {
@ -144,11 +139,21 @@ function SelectMapModal({
for (let file of mapFiles) {
await handleImageUpload(file);
}
clearFileInput();
}
function clearFileInput() {
// Set file input to null to allow adding the same image 2 times in a row
if (fileInputRef.current) {
fileInputRef.current.value = null;
}
}
function handleLargeImageWarningCancel() {
largeImageWarningFiles.current = undefined;
setShowLargeImageWarning(false);
clearFileInput();
}
async function handleLargeImageWarningConfirm() {
@ -158,6 +163,7 @@ function SelectMapModal({
await handleImageUpload(file);
}
largeImageWarningFiles.current = undefined;
clearFileInput();
}
async function handleImageUpload(file) {

View File

@ -90,11 +90,6 @@ function SelectTokensModal({ isOpen, onRequestClose }) {
await navigator.storage.persist();
}
// Set file input to null to allow adding the same image 2 times in a row
if (fileInputRef.current) {
fileInputRef.current.value = null;
}
let tokenFiles = [];
for (let file of files) {
if (file.size > 5e7) {
@ -114,11 +109,21 @@ function SelectTokensModal({ isOpen, onRequestClose }) {
for (let file of tokenFiles) {
await handleImageUpload(file);
}
clearFileInput();
}
function clearFileInput() {
// Set file input to null to allow adding the same image 2 times in a row
if (fileInputRef.current) {
fileInputRef.current.value = null;
}
}
function handleLargeImageWarningCancel() {
largeImageWarningFiles.current = undefined;
setShowLargeImageWarning(false);
clearFileInput();
}
async function handleLargeImageWarningConfirm() {
@ -128,6 +133,7 @@ function SelectTokensModal({ isOpen, onRequestClose }) {
await handleImageUpload(file);
}
largeImageWarningFiles.current = undefined;
clearFileInput();
}
async function handleImageUpload(file) {