Open fmarkulin opened 10 months ago
If I don't put a timeout, the toast doesn't get dismissed, even though the code runs.
here is the code I have:
const mailToast = toast.loading("Pripremanje obavijesti...", { duration: Infinity, }); const user = users.find((user) => user.uid === data.uid); if (!user) { toast.dismiss(mailToast); toast.error("Greška prilikom slanja obavijesti"); return; } const mailParams: EmailParams = { subject: "Dodijeljen termin", to: user.email, name: user.firstname, template: "assign", date: appointmentTimestamp.format("DD.MM.YYYY."), day: appointmentTimestamp.format("dddd"), time: appointmentTimestamp.format("HH:mm"), }; const rejectedMailParams: (EmailParams | undefined)[] = reservations.map( (r) => { const user = users.find((user) => user.uid === r.userId); if (!user) return; return { subject: "Termin zauzet", to: user.email, name: user.firstname, template: "reject", }; }, ); setTimeout(() => { toast.dismiss(mailToast); }, 150); const mailPromise = sendMail(mailParams); toast.promise(mailPromise, { loading: "Slanje obavijesti...", success: "Obavijest poslana!", error: "Greška prilikom slanja obavijesti", }); const rejectedMailPromises = rejectedMailParams.map((params) => params ? sendMail(params) : Promise.resolve(), ); if (rejectedMailPromises.length > 0) toast.promise(Promise.all(rejectedMailPromises), { loading: "Slanje odbijenica...", success: "Odbijenice poslane!", error: "Greška prilikom slanja odbijenica", }); try { await mailPromise; await Promise.all(rejectedMailPromises); } catch (e) {}
Can you provide a codesandbox? I can't run the pasted code as it requires more than what you posted.
This is still an issue btw, let me know if you would like a sandbox reproduction
Describe the feature / bug 📝:
If I don't put a timeout, the toast doesn't get dismissed, even though the code runs.
Steps to reproduce the bug 🔁:
here is the code I have: