[FIX] uploadProgress is not a function (#656)

This commit is contained in:
Diego Mello 2019-02-26 09:47:06 -03:00 committed by GitHub
parent b1236f2f21
commit 025c5cba74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 10 deletions

View File

@ -51,7 +51,7 @@ export async function sendFileMessage(rid, fileInfo) {
try {
database.create('uploads', fileInfo, true);
} catch (e) {
log('sendFileMessage -> create uploads 1', e);
return log('sendFileMessage -> create uploads 1', e);
}
});
@ -62,16 +62,18 @@ export async function sendFileMessage(rid, fileInfo) {
}, data);
// Workaround for https://github.com/joltup/rn-fetch-blob/issues/96
setTimeout(() => {
promises[fileInfo.path].uploadProgress((loaded, total) => {
database.write(() => {
fileInfo.progress = Math.floor((loaded / total) * 100);
try {
database.create('uploads', fileInfo, true);
} catch (e) {
log('sendFileMessage -> create uploads 2', e);
}
if (promises[fileInfo.path] && promises[fileInfo.path].uploadProgress) {
promises[fileInfo.path].uploadProgress((loaded, total) => {
database.write(() => {
fileInfo.progress = Math.floor((loaded / total) * 100);
try {
database.create('uploads', fileInfo, true);
} catch (e) {
return log('sendFileMessage -> create uploads 2', e);
}
});
});
});
}
});
await promises[fileInfo.path];