Skip to content

Commit

Permalink
[FIX] uploadProgress is not a function (#656)
Browse files Browse the repository at this point in the history
  • Loading branch information
diegolmello authored Feb 26, 2019
1 parent b1236f2 commit 025c5cb
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions app/lib/methods/sendFileMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});

Expand All @@ -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];

Expand Down

0 comments on commit 025c5cb

Please sign in to comment.