MDL-78006 course: register activity chooser listeners just once.

This commit is contained in:
Paul Holden
2023-04-24 11:40:31 +01:00
parent 4e632b7251
commit 97f5badba5
3 changed files with 12 additions and 2 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+10
View File
@@ -44,6 +44,8 @@ const ACTIVITIESRESOURCESREC = 5;
const ACTIVITY = 0;
const RESOURCE = 1;
let initialized = false;
/**
* Set up the activity chooser.
*
@@ -67,6 +69,12 @@ export const init = (courseId, chooserConfig) => {
* @param {Object} chooserConfig Any PHP config settings that we may need to reference
*/
const registerListenerEvents = (courseId, chooserConfig) => {
// Ensure we only add our listeners once.
if (initialized) {
return;
}
const events = [
'click',
CustomEvents.events.activate,
@@ -170,6 +178,8 @@ const registerListenerEvents = (courseId, chooserConfig) => {
}
});
});
initialized = true;
};
/**