Fix codex sdk api syntax

This commit is contained in:
Arnaud 2024-09-26 17:11:17 +02:00
parent 1a3d145b63
commit 174a25e85c
No known key found for this signature in database
GPG Key ID: 69D6CE281FCAE663
2 changed files with 17 additions and 22 deletions

View File

@ -138,13 +138,11 @@ export function UploadFile({
const { mutateAsync } = useMutation({
mutationKey: ["upload"],
mutationFn: (file: File) => {
return codexData
.upload(file, onProgress)
.then((res) => {
const res = codexData.upload(file, onProgress);
abort.current = res.abort;
return res.result;
})
.then((safe) =>
return res.result.then((safe) =>
safe.error
? Promise.reject(safe.data.message)
: Promise.resolve(safe.data)

View File

@ -22,14 +22,11 @@ self.addEventListener("message", function (e) {
});
};
return codex.data
.upload(rest.file, onProgress)
.then((result) => {
abort = result.abort;
const res = codex.data.upload(rest.file, onProgress);
return result.result;
})
.then((value) => {
abort = res.abort;
return res.result.then((value) => {
self.postMessage({
type: "completed",
value,