From 025c5cba740ba0824e364429a86bcba26802dd32 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Tue, 26 Feb 2019 09:47:06 -0300 Subject: [PATCH] [FIX] uploadProgress is not a function (#656) --- app/lib/methods/sendFileMessage.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/app/lib/methods/sendFileMessage.js b/app/lib/methods/sendFileMessage.js index 11621a6a47..5d836e96a4 100644 --- a/app/lib/methods/sendFileMessage.js +++ b/app/lib/methods/sendFileMessage.js @@ -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];