Skip to content

Commit

Permalink
[update] put failed results at the end
Browse files Browse the repository at this point in the history
  • Loading branch information
Animenosekai committed Jun 5, 2022
1 parent 6e0c0de commit f1e5f6c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion website/pages/translate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,18 @@ const Translate: NextPage = () => {
}
const data = JSON.parse(event.data)
setResults(results => {
const success = results.filter((val) => val.success)
const failed = results.filter((val) => !val.success)

if (results.length > 0) {
if (results[0] === DefaultTranslateRequest) {
return [data]
} else if (!results[0].success) {
return [data, ...results]
}
}
return [...results, data]
// return [...results, data]
return [...success, data, ...failed]
})
setToLoad(toLoad => toLoad - 1)
}
Expand Down

0 comments on commit f1e5f6c

Please sign in to comment.