Merge pull request #1193 from ItzNotABug/fix-storage-wizard-and-upload-progress

Fix Stuck Uploader Progress on File Upload
This commit is contained in:
Torsten Dittmann authored and GitHub committed 2024-08-27 13:57:20 +02:00
commit fc9742feb1
2 files changed
+11 -4

No files matched your search

+2 -1
View File
@@ -79,7 +79,7 @@ const createUploader = () => {
(p) => {
newFile.$id = p.$id;
newFile.progress = p.progress;
newFile.completed = p.progress === 100 ? true : false;
newFile.completed = p.progress === 100;
updateFile(p.$id, newFile);
}
);
@@ -91,6 +91,7 @@ const createUploader = () => {
removeFromQueue: (id: string) => {
update((n) => {
n.files = n.files.filter((f) => f.$id !== id);
n.isOpen = n.files.length !== 0;
return n;
});
},
@@ -28,17 +28,18 @@
});
async function create() {
const fileId = $createFile.id ?? ID.unique();
try {
uploader.uploadFile(
const uploadPromise = uploader.uploadFile(
bucketId,
$createFile.id ?? ID.unique(),
fileId,
$createFile.files[0],
$createFile.permissions
);
createFile.reset();
wizard.hide();
invalidate(Dependencies.FILES);
addNotification({
type: 'success',
@@ -47,7 +48,12 @@
trackEvent(Submit.FileCreate, {
customId: !!$createFile.id
});
await uploadPromise;
invalidate(Dependencies.FILES);
} catch (e) {
uploader.removeFromQueue(fileId);
addNotification({
type: 'error',
message: e.message