I have this set up where it runs through an array, and saves it into the phone, but it opens the googleUrl before all the media files are downloaded. Shouldn't the Promise.all() take care of this? Isn't it supposed to wait for mapMediaArray
to be finished, and .then()
the rest of the work?
const mapMediaArray = selectedMedia.map(index => {
let cleanUrl = `${index.mediaUrl.split('?')[0]}`;
let extension = cleanUrl.split('.').pop();
RNFetchBlob.config({
fileCache: true,
appendExt: extension,
})
.fetch('GET', index.mediaUrl)
.then(res => {
CameraRoll.saveToCameraRoll(res.path());
});
});
Promise.all(mapMediaArray).then(() => {
Linking.openURL(googleUrl);
});