@@ -19,7 +19,6 @@ angular.module('mm.addons.files')
1919
2020 var path = $stateParams . path ,
2121 root = $stateParams . root ,
22- title ,
2322 promise ;
2423
2524 // We're loading the files.
@@ -32,40 +31,25 @@ angular.module('mm.addons.files')
3231 // The path is unknown, the user must be requesting a root.
3332 if ( root === 'site' ) {
3433 promise = $mmaFiles . getSiteFiles ( ) ;
35- title = $translate ( 'mma.files.sitefiles' ) ;
34+ $scope . title = $translate . instant ( 'mma.files.sitefiles' ) ;
3635 } else if ( root === 'my' ) {
3736 promise = $mmaFiles . getMyFiles ( ) ;
38- title = $translate ( 'mma.files.myprivatefiles' ) ;
37+ $scope . title = $translate . instant ( 'mma.files.myprivatefiles' ) ;
3938 } else {
4039 // Upon error we create a fake promise that is rejected.
4140 promise = $q . reject ( ) ;
42- title = ( function ( ) {
43- var q = $q . defer ( ) ;
44- q . resolve ( '' ) ;
45- return q . promise ;
46- } ) ( ) ;
4741 }
4842 } else {
4943 // Serve the files the user requested.
5044 pathdata = JSON . parse ( path ) ;
5145 promise = $mmaFiles . getFiles ( pathdata ) ;
52-
53- // Put the title in a promise to act like translate does.
54- title = ( function ( ) {
55- var q = $q . defer ( ) ;
56- q . resolve ( $stateParams . title ) ;
57- return q . promise ;
58- } ) ( ) ;
46+ $scope . title = $stateParams . title ;
5947 }
6048
61- return $q . all ( [ promise , title ] ) . then ( function ( data ) {
62- var files = data [ 0 ] ,
63- title = data [ 1 ] ;
64-
49+ return promise . then ( function ( files ) {
6550 $scope . files = files . entries ;
6651 $scope . count = files . count ;
67- $scope . title = title ;
68- } , function ( ) {
52+ } ) . catch ( function ( ) {
6953 $mmUtil . showErrorModal ( 'mma.files.couldnotloadfiles' , true ) ;
7054 } ) ;
7155 }
@@ -84,7 +68,7 @@ angular.module('mm.addons.files')
8468
8569 // Update list if we come from upload page (we don't know if user upoaded a file or not).
8670 // List is invalidated in upload state after uploading a file.
87- $scope . $on ( '$ionicView.enter' , function ( e ) {
71+ $scope . $on ( '$ionicView.enter' , function ( ) {
8872 var forwardView = $ionicHistory . forwardView ( ) ;
8973 if ( forwardView && forwardView . stateName === mmaFilesUploadStateName ) {
9074 $scope . filesLoaded = false ;
0 commit comments