improve streaming error handling

This commit is contained in:
ArnoChen
2025-02-18 00:30:51 +08:00
parent 0c8789035c
commit e083ebb95a
5 changed files with 77 additions and 42 deletions

View File

@@ -29,7 +29,16 @@ export default function DocumentManager() {
try {
const docs = await getDocuments()
if (docs && docs.statuses) {
setDocs(docs)
// compose all documents count
const numDocuments = Object.values(docs.statuses).reduce(
(acc, status) => acc + status.length,
0
)
if (numDocuments > 0) {
setDocs(docs)
} else {
setDocs(null)
}
// console.log(docs)
} else {
setDocs(null)