Skip to content

Commit

Permalink
Use object over order
Browse files Browse the repository at this point in the history
  • Loading branch information
imnasnainaec committed Dec 17, 2024
1 parent 0ef9081 commit 7ba07f5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export function DropWordCardHeader(
const tooltipTexts = [t("mergeDups.helpText.protectedWord")];
const reasons = words[props.wordId]?.protectReasons;
if (reasons?.length) {
tooltipTexts.push(protectReasonsText(t, reasons, []));
tooltipTexts.push(protectReasonsText(t, { word: reasons }));
}
tooltipTexts.push(t("mergeDups.helpText.protectedWordInfo"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default function SenseCardContent(
const tooltipTexts = [t("mergeDups.helpText.protectedSense")];
const reasons = sense.protectReasons;
if (reasons?.length) {
tooltipTexts.push(protectReasonsText(t, [], reasons));
tooltipTexts.push(protectReasonsText(t, { sense: reasons }));
}
tooltipTexts.push(t("mergeDups.helpText.protectedSenseInfo"));

Expand Down
12 changes: 8 additions & 4 deletions src/goals/MergeDuplicates/MergeDupsStep/protectReasonUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ import { ProtectReason, ReasonType } from "api/models";

const sep = "; ";

interface WordSenseReasons {
sense?: ProtectReason[];
word?: ProtectReason[];
}

export function protectReasonsText(
t: TFunction<"translation", undefined>,
wordReasons: ProtectReason[] = [],
senseReasons: ProtectReason[] = []
reasons: WordSenseReasons
): string {
const wordTexts = wordReasons.map((r) => wordReasonText(t, r));
const senseTexts = senseReasons.map((r) => senseReasonText(t, r));
const wordTexts = reasons.word?.map((r) => wordReasonText(t, r)) ?? [];
const senseTexts = reasons.sense?.map((r) => senseReasonText(t, r)) ?? [];
const val = [...wordTexts, ...senseTexts].join(sep);
return t("mergeDups.helpText.protectedData", { val });
}
Expand Down

0 comments on commit 7ba07f5

Please sign in to comment.