Skip to content

Commit

Permalink
MOBILE-4348 resource: Fix unloaded filetype icon
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyserver committed Oct 9, 2023
1 parent 74888f5 commit 71bc83e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/addons/mod/resource/services/handlers/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { makeSingleton, Translate } from '@singletons';
import { AddonModResourceIndexComponent } from '../../components/index';
import { AddonModResource } from '../resource';
import { AddonModResourceHelper } from '../resource-helper';
import { CoreSitesReadingStrategy } from '@services/sites';

/**
* Handler to support resource modules.
Expand Down Expand Up @@ -108,6 +109,16 @@ export class AddonModResourceModuleHandlerService extends CoreModuleHandlerBase
}

try {

if (!module.contentsinfo && !module.contents) {
// Contents are not loaded on LMS 3.5 and 3.6.
await AddonModResource.getResourceData(
module.course,
module.id,
{ readingStrategy: CoreSitesReadingStrategy.PREFER_CACHE },
);
}

handlerData.icon = this.getIconSrc(module);
} catch {
// Ignore errors.
Expand Down Expand Up @@ -158,7 +169,7 @@ export class AddonModResourceModuleHandlerService extends CoreModuleHandlerBase
mimetypeIcon = CoreMimetypeUtils.getMimetypeIcon(mimetype);
}

} else if (module.contents && module.contents[0]) {
} else if (module.contents?.[0]) {
const files = module.contents;
const file = files[0];

Expand Down

0 comments on commit 71bc83e

Please sign in to comment.