From 50adc2056b484dd589c84d3e5b17ae4c320a77ed Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 20 Sep 2017 12:58:41 +0200 Subject: [PATCH] MOBILE-2227 sharedfiles: Close shared file modal when file is shared --- www/core/components/sharedfiles/services/helper.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/www/core/components/sharedfiles/services/helper.js b/www/core/components/sharedfiles/services/helper.js index 78bb7e47fa9..d484033f4a3 100644 --- a/www/core/components/sharedfiles/services/helper.js +++ b/www/core/components/sharedfiles/services/helper.js @@ -21,7 +21,6 @@ angular.module('mm.core.sharedfiles') var self = {}, filePickerDeferred, - fileListModal, fileListScope; /** @@ -115,6 +114,9 @@ angular.module('mm.core.sharedfiles') * @return {Promise} Promise resolved when state changed. */ self.goToChooseSite = function(filePath) { + // If the modal is shown, close it. + fileListScope && fileListScope.closeModal && fileListScope.closeModal(); + var parentState = $state.$current.name.split('.')[0]; return $state.go(parentState + '.sharedfiles-choose-site', {filepath: filePath}); }; @@ -128,14 +130,12 @@ angular.module('mm.core.sharedfiles') * @return {Promise} Promise resolved when the modal is initialized. */ self.initFileListModal = function() { - if (fileListModal) { + if (fileListScope && fileListScope.modal) { // Already initialized. return $q.when(); } - if (!fileListScope) { - fileListScope = $rootScope.$new(); - } + fileListScope = $rootScope.$new(); return $ionicModal.fromTemplateUrl('core/components/sharedfiles/templates/listmodal.html', { scope: fileListScope,