Skip to content

Commit

Permalink
fix success toast
Browse files Browse the repository at this point in the history
  • Loading branch information
xingyaoww committed Nov 8, 2024
1 parent 7e0d086 commit 278fcd2
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions frontend/src/utils/toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,21 @@ export default {
});
idMap.set(id, toastId);
},
success: (id: string, msg: string) => {
const toastId = idMap.get(id);
if (toastId === undefined) return;
if (toastId) {
toast.success(msg, {
id: toastId,
duration: 4000,
style: {
background: "#333",
color: "#fff",
lineBreak: "anywhere",
},
iconTheme: {
primary: "#333",
secondary: "#fff",
},
});
}
idMap.delete(id);
success: (id: string, msg: string, duration: number = 4000) => {
if (idMap.has(id)) return; // prevent duplicate toast
const toastId = toast.success(msg, {
duration: duration,
style: {
background: "#333",
color: "#fff",
lineBreak: "anywhere",
},
iconTheme: {
primary: "#333",
secondary: "#fff",
},
});
idMap.set(id, toastId);
},
settingsChanged: (msg: string) => {
toast(msg, {
Expand Down

0 comments on commit 278fcd2

Please sign in to comment.