From 762d29d082aea7f26f513200a97abd7e65186c20 Mon Sep 17 00:00:00 2001 From: Rahmat Zulfikri Date: Tue, 4 Feb 2020 01:45:40 +0700 Subject: [PATCH] add condition inside download event, before pass it to event callback. --- FS.common.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/FS.common.js b/FS.common.js index cb0e6d40..8ba0b275 100755 --- a/FS.common.js +++ b/FS.common.js @@ -500,15 +500,21 @@ var RNFS = { var subscriptions = []; if (options.begin) { - subscriptions.push(RNFS_NativeEventEmitter.addListener('DownloadBegin', options.begin)); + subscriptions.push(RNFS_NativeEventEmitter.addListener('DownloadBegin', (res) => { + if (res.jobId === jobId) options.begin(res); + })); } if (options.progress) { - subscriptions.push(RNFS_NativeEventEmitter.addListener('DownloadProgress', options.progress)); + subscriptions.push(RNFS_NativeEventEmitter.addListener('DownloadProgress', (res) => { + if (res.jobId === jobId) options.progress(res); + })); } if (options.resumable) { - subscriptions.push(RNFS_NativeEventEmitter.addListener('DownloadResumable', options.resumable)); + subscriptions.push(RNFS_NativeEventEmitter.addListener('DownloadResumable', (res) => { + if (res.jobId === joibId) options.resumable(res); + })); } var bridgeOptions = {