MOBILE-3978 calendar: Add fallback for access info

main
Dani Palou 2022-08-22 09:55:55 +02:00
parent e7b8a824c2
commit fc0d2b1307
1 changed files with 10 additions and 4 deletions

View File

@ -160,14 +160,20 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave {
* @return Promise resolved when done.
*/
protected async fetchData(): Promise<void> {
let accessInfo: AddonCalendarGetCalendarAccessInformationWSResponse;
this.error = false;
// Get access info.
try {
accessInfo = await AddonCalendar.getAccessInformation(this.courseId);
this.types = await AddonCalendar.getAllowedEventTypes(this.courseId);
const [types, accessInfo] = await Promise.all([
AddonCalendar.getAllowedEventTypes(this.courseId),
CoreUtils.ignoreErrors(AddonCalendar.getAccessInformation(this.courseId), {
canmanageentries: false,
canmanageownentries: false,
canmanagegroupentries: false,
} as AddonCalendarGetCalendarAccessInformationWSResponse),
]);
this.types = types;
const promises: Promise<void>[] = [];
const eventTypes = AddonCalendarHelper.getEventTypeOptions(this.types);