MOBILE-4470 contentlinks: Ignore errors calling getActions

main
Dani Palou 2024-05-02 11:59:13 +02:00
parent 023db99e2b
commit b26ed5a25e
2 changed files with 11 additions and 14 deletions

View File

@ -194,7 +194,10 @@ export class CoreContentLinksDelegateService {
return;
}
const actions = await handler.getActions(siteIds, relativeUrl, params, courseId, data);
const actions = await CoreUtils.ignoreErrors(
Promise.resolve(handler.getActions(siteIds, relativeUrl, params, courseId, data)),
<CoreContentLinksAction[]> [],
);
if (actions && actions.length) {
// Set default values if any value isn't supplied.

View File

@ -47,22 +47,16 @@ export class CoreCoursesSectionLinkHandlerService extends CoreCoursesLinksHandle
url: string,
params: Record<string, string>,
): Promise<CoreContentLinksAction[]> {
try {
const siteId = siteIds[0] ?? false;
const sectionId = params.id ? Number(params.id) : false;
const siteHomeId = await CoreSites.getSiteHomeId(siteId);
const course = await this.getSectionCourse(sectionId, siteId);
if (!sectionId || !course || course.id === siteHomeId) {
return [];
}
return this.getCourseActions(url, course.id, { sectionId });
} catch (error) {
this.logger.error(`Failed getting actions for url: '${url}'`, error);
const siteId = siteIds[0] ?? false;
const sectionId = params.id ? Number(params.id) : false;
const siteHomeId = await CoreSites.getSiteHomeId(siteId);
const course = await this.getSectionCourse(sectionId, siteId);
if (!sectionId || !course || course.id === siteHomeId) {
return [];
}
return this.getCourseActions(url, course.id, { sectionId });
}
/**