MOBILE-2915 core: Show file not found error if no files

main
Dani Palou 2019-03-29 12:46:04 +01:00
parent ceff8858f4
commit 201a703258
4 changed files with 7 additions and 3 deletions

View File

@ -15,6 +15,7 @@
import { Component, Injector } from '@angular/core';
import { CoreAppProvider } from '@providers/app';
import { CoreSitesProvider } from '@providers/sites';
import { CoreUtilsProvider } from '@providers/utils/utils';
import { CoreCourseProvider } from '@core/course/providers/course';
import { CoreCourseModuleMainResourceComponent } from '@core/course/classes/main-resource-component';
import { AddonModResourceProvider } from '../../providers/resource';
@ -38,7 +39,8 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource
constructor(injector: Injector, private resourceProvider: AddonModResourceProvider, private courseProvider: CoreCourseProvider,
private appProvider: CoreAppProvider, private prefetchHandler: AddonModResourcePrefetchHandler,
private resourceHelper: AddonModResourceHelperProvider, private sitesProvider: CoreSitesProvider) {
private resourceHelper: AddonModResourceHelperProvider, private sitesProvider: CoreSitesProvider,
private utils: CoreUtilsProvider) {
super(injector);
}
@ -78,7 +80,7 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource
// Load module contents if needed. Passing refresh is needed to force reloading contents.
return this.courseProvider.loadModuleContents(this.module, this.courseId, null, false, refresh).then(() => {
if (!this.module.contents || !this.module.contents.length) {
return Promise.reject(null);
return Promise.reject(this.utils.createFakeWSError('core.filenotfound', true));
}
// Get the resource instance to get the latest name/description and to know if it's embedded.

View File

@ -1342,6 +1342,7 @@
"core.favourites": "Starred",
"core.filename": "Filename",
"core.filenameexist": "File name already exists: {{$a}}",
"core.filenotfound": "File not found, sorry.",
"core.fileuploader.addfiletext": "Add file",
"core.fileuploader.audio": "Audio",
"core.fileuploader.camera": "Camera",

View File

@ -528,7 +528,7 @@ export class CoreCourseHelperProvider {
// Make sure that module contents are loaded.
return promise.then(() => {
if (!files || !files.length) {
return Promise.reject(null);
return Promise.reject(this.utils.createFakeWSError('core.filenotfound', true));
}
return this.sitesProvider.getSite(siteId);

View File

@ -95,6 +95,7 @@
"favourites": "Starred",
"filename": "Filename",
"filenameexist": "File name already exists: {{$a}}",
"filenotfound": "File not found, sorry.",
"folder": "Folder",
"forcepasswordchangenotice": "You must change your password to proceed.",
"fulllistofcourses": "All courses",