Skip to content

Commit

Permalink
Merge pull request #1193 from ItzNotABug/fix-storage-wizard-and-uploa…
Browse files Browse the repository at this point in the history
…d-progress

Fix Stuck Uploader Progress on File Upload
  • Loading branch information
TorstenDittmann committed Aug 27, 2024
2 parents 18c2cdc + 8ecfe96 commit fc9742f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/lib/stores/uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
);
Expand All @@ -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;
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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
Expand Down

0 comments on commit fc9742f

Please sign in to comment.