From 1ffba1b7e8342b693a984239ec09b3fc96e808a8 Mon Sep 17 00:00:00 2001 From: cpojer Date: Fri, 1 Nov 2024 10:15:22 +0900 Subject: [PATCH] Do not hide labels of a hidden objective if a visible objective matching the same label exists. GitOrigin-RevId: 21bd31d10162cdfdd9aad5f093686af381b6cb45 --- athena/Objectives.tsx | 28 +++++++++++------------ hera/editor/lib/ObjectiveCard.tsx | 24 ++++++++++++-------- tests/__tests__/EntityLabel.test.tsx | 34 +++++++++++++++++++++++++++- 3 files changed, 61 insertions(+), 25 deletions(-) diff --git a/athena/Objectives.tsx b/athena/Objectives.tsx index 330c9b73..43955244 100644 --- a/athena/Objectives.tsx +++ b/athena/Objectives.tsx @@ -923,26 +923,26 @@ export function getHiddenLabels(objectives: Objectives): PlayerIDSet | null { return null; } - let labels: Set | null = null; + const labels: Array = []; + const visibleLabels = new Set(); for (const [, objective] of objectives) { - if ( - objective.hidden && - objectiveHasLabel(objective) && - objective.label && - (!objective.optional || - !objective.completed || - objective.completed.size < 1) - ) { + if (objectiveHasLabel(objective) && objective.label) { for (const label of objective.label) { - if (!labels) { - labels = new Set(); + if ( + objective.hidden && + (!objective.optional || + !objective.completed || + objective.completed.size < 1) + ) { + labels.push(label); + } else { + visibleLabels.add(label); } - - labels.add(label); } } } - return labels; + const hiddenLabels = labels.filter((label) => !visibleLabels.has(label)); + return hiddenLabels.length ? new Set(hiddenLabels) : null; } export function getInitialObjective( diff --git a/hera/editor/lib/ObjectiveCard.tsx b/hera/editor/lib/ObjectiveCard.tsx index 9925875e..79f33d59 100644 --- a/hera/editor/lib/ObjectiveCard.tsx +++ b/hera/editor/lib/ObjectiveCard.tsx @@ -267,9 +267,9 @@ export default function ObjectiveCard({ )} - -