MDL-74987 core_courseformat: add pending to refresh activity

The activity reload was missing a pending control. This can lead to
behat errors if the module refresh takes longer than expected for some
reason.
This commit is contained in:
Ferran Recio
2023-01-04 09:25:52 +01:00
parent fe4784e60f
commit a3264eb5e0
3 changed files with 8 additions and 3 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+5
View File
@@ -33,6 +33,7 @@ import DispatchActions from 'core_courseformat/local/content/actions';
import * as CourseEvents from 'core_course/events';
// The jQuery module is only used for interacting with Boostrap 4. It can we removed when MDL-71979 is integrated.
import jQuery from 'jquery';
import Pending from 'core/pending';
export default class Component extends BaseComponent {
@@ -502,11 +503,13 @@ export default class Component extends BaseComponent {
* @param {object} param0.element the state object
*/
_reloadCm({element}) {
const pendingReload = new Pending(`courseformat/content:reloadCm_${element.id}`);
const cmitem = this.getElement(this.selectors.CM, element.id);
if (cmitem) {
const promise = courseActions.refreshModule(cmitem, element.id);
promise.then(() => {
this._indexContents();
pendingReload.resolve();
return;
}).catch();
}
@@ -522,11 +525,13 @@ export default class Component extends BaseComponent {
* @param {object} param0.element the state object
*/
_reloadSection({element}) {
const pendingReload = new Pending(`courseformat/content:reloadSection_${element.id}`);
const sectionitem = this.getElement(this.selectors.SECTION, element.id);
if (sectionitem) {
const promise = courseActions.refreshSection(sectionitem, element.id);
promise.then(() => {
this._indexContents();
pendingReload.resolve();
return;
}).catch();
}