v7.1.2
This commit is contained in:
@@ -5,41 +5,49 @@ import { getSettings } from "./settings";
|
||||
const toastStyle = {
|
||||
className: "font-mono lowercase",
|
||||
};
|
||||
type ToastData = Parameters<typeof toast.success>[1];
|
||||
const isSfxEnabled = () => getSettings().sfxEnabled;
|
||||
export const toastWithSound = {
|
||||
success: (message: string, data?: any) => {
|
||||
success: (message: string, data?: ToastData) => {
|
||||
const msg = message.toLowerCase();
|
||||
logger.success(msg);
|
||||
if (isSfxEnabled())
|
||||
playSuccessSound();
|
||||
return toast.success(msg, { ...toastStyle, ...data });
|
||||
},
|
||||
error: (message: string, data?: any) => {
|
||||
error: (message: string, data?: ToastData) => {
|
||||
const msg = message.toLowerCase();
|
||||
logger.error(msg);
|
||||
if (isSfxEnabled())
|
||||
playErrorSound();
|
||||
return toast.error(msg, { ...toastStyle, ...data });
|
||||
},
|
||||
warning: (message: string, data?: any) => {
|
||||
warning: (message: string, data?: ToastData) => {
|
||||
const msg = message.toLowerCase();
|
||||
logger.warning(msg);
|
||||
if (isSfxEnabled())
|
||||
playWarningSound();
|
||||
return toast.warning(msg, { ...toastStyle, ...data });
|
||||
},
|
||||
info: (message: string, data?: any) => {
|
||||
info: (message: string, data?: ToastData) => {
|
||||
const msg = message.toLowerCase();
|
||||
logger.info(msg);
|
||||
if (isSfxEnabled())
|
||||
playInfoSound();
|
||||
return toast.info(msg, { ...toastStyle, ...data });
|
||||
},
|
||||
message: (message: string, data?: any) => {
|
||||
message: (message: string, data?: ToastData) => {
|
||||
const msg = message.toLowerCase();
|
||||
logger.info(msg);
|
||||
if (isSfxEnabled())
|
||||
playInfoSound();
|
||||
return toast(msg, { ...toastStyle, ...data });
|
||||
},
|
||||
silentInfo: (message: string, data?: ToastData) => {
|
||||
const msg = message.toLowerCase();
|
||||
logger.info(msg);
|
||||
return toast.info(msg, { ...toastStyle, ...data });
|
||||
},
|
||||
dismiss: (id?: string | number) => toast.dismiss(id),
|
||||
toast: toast,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user