Skip to content

Commit afd0441

Browse files
committed
Fix empty event when loading all settings
1 parent fe544f9 commit afd0441

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

internal/Trigger.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,14 @@ const triggers = {
113113
* @function
114114
* @param {string} [option]
115115
* @param {Object} [optionValue] will be automatically retrieved, if not given
116-
* @param {Event} event the event (input or change) that triggered saving
116+
* @param {Event} [event] the event (input or change) that triggered saving
117117
* @returns {Promise}
118118
* @see {@link saveTrigger}
119119
*/
120-
export async function runSaveTrigger(option, optionValue, event) {
120+
export async function runSaveTrigger(option, optionValue, event = {}) {
121+
// default event parameter to empty object
122+
event = event || {};
123+
121124
if (option === undefined) {
122125
console.info("run all save triggers");
123126

@@ -126,7 +129,7 @@ export async function runSaveTrigger(option, optionValue, event) {
126129
const option = trigger.option;
127130
const optionValue = await OptionsModel.getOption(option);
128131

129-
promises.push(trigger.triggerFunc(optionValue, option));
132+
promises.push(trigger.triggerFunc(optionValue, option, event));
130133
}
131134
return Promise.all(promises);
132135
}
@@ -158,11 +161,11 @@ export async function runSaveTrigger(option, optionValue, event) {
158161
* @param {string} option
159162
* @param {Object} optionValue
160163
* @param {Array} saveTriggerValues value returned by potentially run safe triggers
161-
* @param {Event} event the event (input or change) that triggered saving
164+
* @param {Event} [event] the event (input or change) that triggered saving
162165
* @returns {Promise}
163166
* @see {@link overrideSave}
164167
*/
165-
export async function runOverrideSave(option, optionValue, saveTriggerValues, event) {
168+
export async function runOverrideSave(option, optionValue, saveTriggerValues, event = {}) {
166169
// run all registered triggers for that option
167170
const allRegisteredOverrides = triggers.overrideSave.filter((trigger) => trigger.option === option);
168171
if (allRegisteredOverrides.length === 0) {
@@ -171,6 +174,9 @@ export async function runOverrideSave(option, optionValue, saveTriggerValues, ev
171174

172175
console.info("runOverrideSave:", `${allRegisteredOverrides.length}x`, option, optionValue);
173176

177+
// default event parameter to empty object
178+
event = event || {};
179+
174180
let lastPromise = Promise.resolve({
175181
option,
176182
optionValue,

0 commit comments

Comments
 (0)