- this.upload.getApi().done( function ( api ) {
- // If the user can't upload anything, don't give them the option to.
- api.getUserInfo().done( function ( userInfo ) {
- if ( userInfo.rights.indexOf( 'upload' ) === -1 ) {
- // TODO Use a better error message when not all logged-in users can upload
- booklet.getPage( 'upload' ).$element.msg( 'api-error-mustbeloggedin' );
- }
- } ).always( function () {
- deferred.resolve();
- } );
- } ).fail( function ( errorMsg ) {
- booklet.getPage( 'upload' ).$element.msg( errorMsg );
- deferred.resolve();
- } );
-
- return deferred.promise();
+ return this.upload.getApi().then(
+ function ( api ) {
+ // If the user can't upload anything, don't give them the option to.
+ return api.getUserInfo().then(
+ function ( userInfo ) {
+ if ( userInfo.rights.indexOf( 'upload' ) === -1 ) {
+ // TODO Use a better error message when not all logged-in users can upload
+ booklet.getPage( 'upload' ).$element.msg( 'api-error-mustbeloggedin' );
+ }
+ return $.Deferred().resolve();
+ },
+ function () {
+ return $.Deferred().resolve();
+ }
+ );
+ },
+ function ( errorMsg ) {
+ booklet.getPage( 'upload' ).$element.msg( errorMsg );
+ return $.Deferred().resolve();
+ }
+ );