diff --git a/src/addons/mod/bigbluebuttonbn/components/index/index.ts b/src/addons/mod/bigbluebuttonbn/components/index/index.ts index 610226d45..f7dbbe3f9 100644 --- a/src/addons/mod/bigbluebuttonbn/components/index/index.ts +++ b/src/addons/mod/bigbluebuttonbn/components/index/index.ts @@ -17,6 +17,7 @@ import { CoreError } from '@classes/errors/error'; import { CoreCourseModuleMainActivityComponent } from '@features/course/classes/main-activity-component'; import { CoreCourseContentsPage } from '@features/course/pages/contents/contents'; import { IonContent } from '@ionic/angular'; +import { CoreApp } from '@services/app'; import { CoreGroupInfo, CoreGroups } from '@services/groups'; import { CoreDomUtils } from '@services/utils/dom'; import { CoreUtils } from '@services/utils/utils'; @@ -79,9 +80,10 @@ export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityCompo /** * Get meeting info. * + * @param updateCache Whether to update info cached data (in server). * @return Promise resolved when done. */ - async fetchMeetingInfo(): Promise { + async fetchMeetingInfo(updateCache?: boolean): Promise { if (!this.bbb) { return; } @@ -89,6 +91,7 @@ export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityCompo try { this.meetingInfo = await AddonModBBB.getMeetingInfo(this.bbb.id, this.groupId, { cmId: this.module.id, + updateCache, }); if (this.meetingInfo.statusrunning && this.meetingInfo.userlimit > 0) { @@ -120,9 +123,10 @@ export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityCompo /** * Update meeting info. * + * @param updateCache Whether to update info cached data (in server). * @return Promise resolved when done. */ - async updateMeetingInfo(): Promise { + async updateMeetingInfo(updateCache?: boolean): Promise { if (!this.bbb) { return; } @@ -132,7 +136,7 @@ export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityCompo try { await AddonModBBB.invalidateAllGroupsMeetingInfo(this.bbb.id); - await this.fetchMeetingInfo(); + await this.fetchMeetingInfo(updateCache); } finally { this.showLoading = false; } @@ -182,11 +186,14 @@ export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityCompo try { const joinUrl = await AddonModBBB.getJoinUrl(this.module.id, this.groupId); - CoreUtils.openInBrowser(joinUrl, { + await CoreUtils.openInBrowser(joinUrl, { showBrowserWarning: false, }); - this.updateMeetingInfo(); + // Leave some time for the room to load. + await CoreApp.waitForResume(10000); + + this.updateMeetingInfo(true); } catch (error) { CoreDomUtils.showErrorModal(error); } finally { diff --git a/src/addons/mod/bigbluebuttonbn/services/bigbluebuttonbn.ts b/src/addons/mod/bigbluebuttonbn/services/bigbluebuttonbn.ts index fb64603ee..411aa5252 100644 --- a/src/addons/mod/bigbluebuttonbn/services/bigbluebuttonbn.ts +++ b/src/addons/mod/bigbluebuttonbn/services/bigbluebuttonbn.ts @@ -151,7 +151,7 @@ export class AddonModBBBService { async getMeetingInfo( id: number, groupId: number = 0, - options: CoreCourseCommonModWSOptions = {}, + options: AddonModBBBGetMeetingInfoOptions = {}, ): Promise { const site = await CoreSites.getSite(options.siteId); @@ -161,10 +161,16 @@ export class AddonModBBBService { }; const preSets: CoreSiteWSPreSets = { cacheKey: this.getMeetingInfoCacheKey(id, groupId), + getCacheUsingCacheKey: true, + uniqueCacheKey: true, component: AddonModBBBService.COMPONENT, componentId: options.cmId, ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets. }; + if (options.updateCache) { + params.updatecache = true; + preSets.getFromCache = false; + } return site.read( 'mod_bigbluebuttonbn_meeting_info', @@ -380,3 +386,10 @@ export type AddonModBBBEndMeetingWSParams = { bigbluebuttonbnid: number; // Bigbluebuttonbn instance id. groupid?: number; // Bigbluebuttonbn group id. }; + +/** + * Options for getMeetingInfo. + */ +export type AddonModBBBGetMeetingInfoOptions = CoreCourseCommonModWSOptions & { + updateCache?: boolean; +};