Skip to content
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
2 changes: 1 addition & 1 deletion ui/raidboss/popup-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ export class PopupText {
}
uniqueById.set(triggerSet.id, triggerSet);
}
this.triggerSets = [...noIdList, ...uniqueById.values()];
this.triggerSets = [...uniqueById.values(), ...noIdList];
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, this moves the triggers without an ID to the end so that they'll override anything before them?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Since built-in triggers always have IDs, the current load order is:
[Built-in -> User (w/ ID) -> User (w/o ID)]

However, if we want to respect the user's original file loading order:
[Built-in -> User A (w/ ID) -> User B (w/o ID) -> User C (w/ ID)]

It might be better to do this instead:

    const lastVersionOfId = new Map<string, typeof this.triggerSets[number]>();
    for (const set of this.triggerSets) {
      if (set.id !== undefined) {
        const existing = lastVersionOfId.get(set.id);
        if (existing !== undefined) {
          console.log(
            `Overriding trigger set id '${set.id}' from '${existing.filename}' with '${set.filename}'`,
          );
        }
        lastVersionOfId.set(set.id, set);
      }
    }

    this.triggerSets = this.triggerSets.filter((set) => {
      if (set.id === undefined)
        return true;
      return lastVersionOfId.get(set.id) === set;
    });
    this.triggerSetsById = Object.fromEntries(lastVersionOfId);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll push this version to stay consistent with the original load order.

this.triggerSetsById = Object.fromEntries(uniqueById);
}

Expand Down