Skip to content

Commit 6421f1e

Browse files
authored
Merge pull request #119 from Coding-Club-IITG/aditya
Fixed Toast for download
2 parents 2e58621 + 7b09a3d commit 6421f1e

File tree

1 file changed

+13
-1
lines changed
  • client/src/screens/browse/components/folder-info

1 file changed

+13
-1
lines changed

client/src/screens/browse/components/folder-info/index.jsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,22 @@ const FolderInfo = ({
193193

194194
// Usage function remains the same
195195
const downloadAndSaveFolder = async (folderId, folderName = "folder") => {
196+
let toastId;
196197
try {
197-
toast.info("Preparing to download folder...");
198+
// Create a persistent toast that doesn't auto-close
199+
toastId = toast.info("Preparing to download folder...", {
200+
autoClose: false,
201+
closeOnClick: false,
202+
closeButton: false,
203+
draggable: false,
204+
});
198205

199206
// Use either the fixed version or the alternative approach
200207
const zip = await downloadFolder(folderId);
201208
// const zip = await downloadFolderAlternative(folderId);
202209

203210
if (!zip) {
211+
toast.dismiss(toastId);
204212
toast.error("Failed to create folder archive.");
205213
return;
206214
}
@@ -215,9 +223,13 @@ const FolderInfo = ({
215223
// Save the ZIP file using saveAs
216224
saveAs(zipBlob, `${folderName}.zip`);
217225

226+
toast.dismiss(toastId);
218227
toast.success("Folder Ready for download!");
219228
} catch (error) {
220229
console.error("Error in downloadAndSaveFolder:", error);
230+
if (toastId) {
231+
toast.dismiss(toastId);
232+
}
221233
toast.error("Failed to download folder.");
222234
}
223235
};

0 commit comments

Comments
 (0)