Skip to content

Commit

Permalink
fix: import not fixing up nested actions/feedbacks correctly #3248
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Feb 4, 2025
1 parent 1de3221 commit 34dfe8d
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions companion/lib/Resources/Visitors/ReferencesVisitors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,34 @@ export class ReferencesVisitors {
// Update the base style
if (style) visitor.visitString(style, 'text')

const flatRawFeedbacks: FeedbackInstance[] = []
const pluckRawFeedbacks = (feedbacks: FeedbackInstance[]) => {
for (const feedback of feedbacks) {
flatRawFeedbacks.push(feedback)
if (feedback.instance_id === 'internal' && feedback.children) {
pluckRawFeedbacks(feedback.children)
}
}
}
pluckRawFeedbacks(rawFeedbacks)

const flatRawActions: ActionInstance[] = []
const pluckRawActions = (actions: ActionInstance[]) => {
for (const action of actions) {
flatRawActions.push(action)
if (action.instance === 'internal' && action.children) {
for (const children of Object.values(action.children)) {
if (children) pluckRawActions(children)
}
}
}
}
pluckRawActions(rawActions)

// Apply any updates to the internal actions/feedbacks
internalModule.visitReferences(visitor, rawActions, actions, rawFeedbacks, feedbacks)
internalModule.visitReferences(visitor, flatRawActions, actions, flatRawFeedbacks, feedbacks)

for (const feedback of rawFeedbacks) {
for (const feedback of flatRawFeedbacks) {
visitFeedbackInstance(visitor, feedback)
}

Expand All @@ -48,7 +72,7 @@ export class ReferencesVisitors {
}

// Fixup any references in action options
for (const action of rawActions) {
for (const action of flatRawActions) {
visitActionInstance(visitor, action)
}

Expand Down

0 comments on commit 34dfe8d

Please sign in to comment.