small cleanup
This commit is contained in:
parent
0f731976c0
commit
1e5b1c78e7
|
@ -125,7 +125,6 @@ export function sendFileMessage(
|
||||||
uploadQueue[uploadPath].then(async response => {
|
uploadQueue[uploadPath].then(async response => {
|
||||||
// If response is all good...
|
// If response is all good...
|
||||||
if (response.respInfo.status >= 200 && response.respInfo.status < 400) {
|
if (response.respInfo.status >= 200 && response.respInfo.status < 400) {
|
||||||
try {
|
|
||||||
const json = response.json();
|
const json = response.json();
|
||||||
let content;
|
let content;
|
||||||
if (getContent) {
|
if (getContent) {
|
||||||
|
@ -150,24 +149,12 @@ export function sendFileMessage(
|
||||||
await uploadRecord.destroyPermanently();
|
await uploadRecord.destroyPermanently();
|
||||||
});
|
});
|
||||||
resolve(response);
|
resolve(response);
|
||||||
} catch (e) {
|
|
||||||
log(e);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
|
||||||
await db.write(async () => {
|
await db.write(async () => {
|
||||||
await uploadRecord.update(u => {
|
await uploadRecord.update(u => {
|
||||||
u.error = true;
|
u.error = true;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} catch (e) {
|
|
||||||
log(e);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
reject(response);
|
|
||||||
} catch (e) {
|
|
||||||
reject(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -181,22 +168,18 @@ export function sendFileMessage(
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(e);
|
log(e);
|
||||||
}
|
}
|
||||||
reject(error);
|
throw error;
|
||||||
});
|
});
|
||||||
|
|
||||||
uploadQueue[uploadPath].uploadProgress(async (loaded: number, total: number) => {
|
uploadQueue[uploadPath].uploadProgress(async (loaded: number, total: number) => {
|
||||||
try {
|
|
||||||
await db.write(async () => {
|
await db.write(async () => {
|
||||||
await uploadRecord.update(u => {
|
await uploadRecord.update(u => {
|
||||||
u.progress = Math.floor((loaded / total) * 100);
|
u.progress = Math.floor((loaded / total) * 100);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} catch (e) {
|
|
||||||
log(e);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(e);
|
reject(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue