Skip to content
Open
Changes from all commits
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
33 changes: 18 additions & 15 deletions ui/raidboss/popup-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -704,23 +704,26 @@ export class PopupText {
this.triggerSets.push(...this.options.Triggers);

// Eliminate any trigger sets with duplicate ids, allowing later ones to override earlier ones.
const uniqueById = new Map<string, typeof this.triggerSets[number]>();
const noIdList: typeof this.triggerSets = [];
for (const triggerSet of this.triggerSets) {
if (triggerSet.id === undefined) {
noIdList.push(triggerSet);
continue;
}
const existing = uniqueById.get(triggerSet.id);
if (existing !== undefined) {
console.log(
`Overriding trigger set id '${triggerSet.id}' from '${existing.filename}' with '${triggerSet.filename}'`,
);
// Filter the list to keep the last instance of each ID while preserving order.
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);
}
uniqueById.set(triggerSet.id, triggerSet);
}
this.triggerSets = [...noIdList, ...uniqueById.values()];
this.triggerSetsById = Object.fromEntries(uniqueById);

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

OnChangeZone(e: EventResponses['ChangeZone']): void {
Expand Down