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