Improve toast notifications and document clearing flow
- Enhanced Toaster component with theme, close button and rich colors - Added immediate feedback for document clearing operation
This commit is contained in:
@@ -80,7 +80,12 @@ const AppRouter = () => {
|
||||
<ThemeProvider>
|
||||
<Router>
|
||||
<AppContent />
|
||||
<Toaster position="bottom-center" />
|
||||
<Toaster
|
||||
position="bottom-center"
|
||||
theme="system"
|
||||
closeButton
|
||||
richColors
|
||||
/>
|
||||
</Router>
|
||||
</ThemeProvider>
|
||||
)
|
||||
|
@@ -61,6 +61,14 @@ export default function ClearDocumentsDialog({ onDocumentsCleared }: ClearDocume
|
||||
try {
|
||||
const result = await clearDocuments()
|
||||
|
||||
if (result.status !== 'success') {
|
||||
toast.error(t('documentPanel.clearDocuments.failed', { message: result.message }))
|
||||
setConfirmText('')
|
||||
return
|
||||
}
|
||||
|
||||
toast.success(t('documentPanel.clearDocuments.success'))
|
||||
|
||||
if (clearCacheOption) {
|
||||
try {
|
||||
await clearCache()
|
||||
@@ -70,28 +78,19 @@ export default function ClearDocumentsDialog({ onDocumentsCleared }: ClearDocume
|
||||
}
|
||||
}
|
||||
|
||||
if (result.status === 'success') {
|
||||
toast.success(t('documentPanel.clearDocuments.success'))
|
||||
} else {
|
||||
toast.error(t('documentPanel.clearDocuments.failed', { message: result.message }))
|
||||
}
|
||||
} catch (err) {
|
||||
toast.error(t('documentPanel.clearDocuments.error', { error: errorMessage(err) }))
|
||||
} finally {
|
||||
// Execute these operations regardless of success or failure
|
||||
try {
|
||||
// Update backend state
|
||||
// Update health check status
|
||||
await check()
|
||||
|
||||
// Refresh document list
|
||||
// Refresh document list if provided
|
||||
if (onDocumentsCleared) {
|
||||
await onDocumentsCleared()
|
||||
}
|
||||
} catch (refreshErr) {
|
||||
console.error('Error refreshing state:', refreshErr)
|
||||
}
|
||||
|
||||
// 所有操作成功后关闭对话框
|
||||
setOpen(false)
|
||||
} catch (err) {
|
||||
toast.error(t('documentPanel.clearDocuments.error', { error: errorMessage(err) }))
|
||||
setConfirmText('')
|
||||
}
|
||||
}, [isConfirmEnabled, clearCacheOption, setOpen, t, check, onDocumentsCleared])
|
||||
|
||||
|
Reference in New Issue
Block a user