mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-03 19:30:04 +08:00
refactor(toast): remove deprecated toast utilities and update comment
Remove deprecated toast API functions that were no-ops and update dataLimit comment to reflect current toast limitations
This commit is contained in:
parent
b878315491
commit
17d9da6f4e
@ -178,51 +178,9 @@ export const loading = (args: RequireSome<LoadingToastConfig, 'promise'>): strin
|
||||
*/
|
||||
export const addToast = (config: ToastConfig) => info(config)
|
||||
|
||||
/**
|
||||
* Close a specific toast notification by its key
|
||||
* @param key - Toast key (string)
|
||||
*/
|
||||
export const closeToast = (key: string) => {
|
||||
getMessageApi().destroy(key)
|
||||
}
|
||||
|
||||
/**
|
||||
* Close all toast notifications
|
||||
*/
|
||||
export const closeAll = () => {
|
||||
getMessageApi().destroy()
|
||||
}
|
||||
|
||||
/**
|
||||
* Stub functions for compatibility with previous toast API
|
||||
* These are no-ops since antd message doesn't expose a queue
|
||||
*/
|
||||
|
||||
/**
|
||||
* @deprecated This function is a no-op stub for backward compatibility only.
|
||||
* Antd message doesn't expose a queue. Do not rely on this function.
|
||||
* @returns Empty toast queue stub
|
||||
*/
|
||||
export const getToastQueue = (): any => ({ toasts: [] })
|
||||
|
||||
/**
|
||||
* @deprecated This function is a no-op stub for backward compatibility only.
|
||||
* Antd message doesn't track closing state. Do not rely on this function.
|
||||
* @param key - Toast key (unused)
|
||||
* @returns Always returns false
|
||||
*/
|
||||
export const isToastClosing = (key?: string): boolean => {
|
||||
key // unused
|
||||
return false
|
||||
}
|
||||
|
||||
export const getToastUtilities = () =>
|
||||
({
|
||||
getToastQueue,
|
||||
addToast,
|
||||
closeToast,
|
||||
closeAll,
|
||||
isToastClosing,
|
||||
error,
|
||||
success,
|
||||
warning,
|
||||
|
||||
@ -83,8 +83,8 @@ export async function checkDataLimit() {
|
||||
}
|
||||
currentInterval = setInterval(check, CHECK_INTERVAL_WARNING)
|
||||
} else if (!shouldShowWarning && currentToastId) {
|
||||
// Dismiss toast when space is recovered
|
||||
window.toast.closeToast(currentToastId)
|
||||
// TODO: new toast component cannot be closed programmatically. add a dismiss button in the toast.
|
||||
// window.toast.closeToast(currentToastId)
|
||||
currentToastId = null
|
||||
|
||||
// Switch back to normal mode
|
||||
|
||||
Loading…
Reference in New Issue
Block a user