Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions Composer/packages/lib/indexers/src/groupTriggers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const getPropertyReferences = (content: any) => {
return uniq(foundProperties);
};

const getTriggerPropertyReferences = (trigger: ITrigger) => {
const getTriggerPropertyReferences = (trigger: ITrigger, isValidProperty: (name: string) => boolean) => {
const content = trigger.content;

// inspect trigger
Expand All @@ -52,7 +52,7 @@ const getTriggerPropertyReferences = (trigger: ITrigger) => {
}
}

const result = uniq(foundProperties);
const result = uniq(foundProperties).filter(isValidProperty);

if (result.length === 0) {
return [NoGroupingTriggerGroupName];
Expand All @@ -76,18 +76,16 @@ export const groupTriggersByPropertyReference = (
): Record<string, ITrigger[]> => {
const result = {} as Record<string, ITrigger[]>;

const validProperties = options?.validProperties;
const isValidProperty = validProperties
? (x: string | undefined) => x && (x === NoGroupingTriggerGroupName || validProperties.includes(x))
: () => true;
const isValidProperty = (name: string) =>
!options?.validProperties || name === NoGroupingTriggerGroupName || options?.validProperties.includes(name);

const addResult = (property: string, trigger: ITrigger) => {
result[property] ? result[property].push(trigger) : (result[property] = [trigger]);
};

if (dialog?.triggers) {
dialog.triggers.forEach((t) => {
const properties = getTriggerPropertyReferences(t).filter(isValidProperty);
const properties = getTriggerPropertyReferences(t, isValidProperty);
if (properties.length > 1 && options?.allowMultiParent) {
properties.forEach((p) => {
addResult(p, t);
Expand Down