Skip to content

Commit

Permalink
fix: remove progress bar in toast
Browse files Browse the repository at this point in the history
  • Loading branch information
trobonox committed Aug 14, 2023
1 parent d11e0be commit 6755deb
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/utils/files.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { auth } from "@/stores/auth";
import type { UploadedFile } from "@/types/api";
import { createSignal } from "solid-js";
import toast from "solid-toast";

export const createFileImporter = (onFileUploaded: (files: FileList) => unknown) => {
Expand Down Expand Up @@ -80,8 +79,6 @@ export const getUploadedFileURL = (file: UploadedFile) => {
return url;
};

const [downloadProgress, setDownloadProgress] = createSignal(0);

export const downloadUploadedFile = (file: UploadedFile) => {
const xhr = new XMLHttpRequest();
xhr.open("GET", "/api/file/" + file.id, true);
Expand All @@ -92,8 +89,7 @@ export const downloadUploadedFile = (file: UploadedFile) => {
toast.custom(() => (
<div
class="relative flex flex-col gap-2 rounded-md bg-base px-6 py-3 pr-12 font-medium text-text shadow-md">
Downloading... {downloadProgress()}%
<progress value={downloadProgress()} max={100} class="bg-lavender" />
Downloading your file, please wait...
</div>
), {
unmountDelay: 0
Expand Down Expand Up @@ -121,7 +117,6 @@ export const downloadUploadedFile = (file: UploadedFile) => {
xhr.onprogress = (event) => {
if (event.lengthComputable) {
console.info(file.name, `${event.loaded}/${event.total} (${event.loaded * 100 / event.total}%)`);
setDownloadProgress(Math.floor(event.loaded * 100 / event.total));

if (event.loaded === 1) {
toast.dismiss();
Expand Down

0 comments on commit 6755deb

Please sign in to comment.