Skip to content

Commit 76fd76e

Browse files
authored
Tweak scratch match banner text (lower -> better) (#1768)
1 parent 3d5e7bd commit 76fd76e

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

frontend/src/components/Scratch/ScratchMatchBanner.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,25 @@ export default function ScratchMatchBanner({
3535

3636
if (scratch.score === 0 || !match) return null;
3737

38-
const isMatch = match.score === 0;
38+
const isMatch = match.score === 0 || match.match_override;
39+
const subject = userIsYou(match.owner)
40+
? "You have"
41+
: `${match.owner?.username ?? "A user"} has`;
3942

40-
const percent = calculateScorePercent(match.score, match.max_score);
41-
const percentString = percent !== 0 ? percentToString(percent) : "";
43+
const percent = !isMatch
44+
? calculateScorePercent(match.score, match.max_score)
45+
: null;
46+
const percentString = percent ? ` (${percentToString(percent)})` : "";
4247

43-
let message = `This function has ${isMatch ? "been matched" : "a lower-scoring scratch"}`;
44-
if (userIsYou(match.owner)) message += " by you, elsewhere";
45-
else if (match.owner) message += ` by ${match.owner.username}`;
46-
47-
if (!isMatch)
48-
message += `. Improved score is ${match.score.toLocaleString("en-US")} ${percentString && `(${percentString})`}`;
48+
const message = isMatch
49+
? `${subject} matched this scratch elsewhere. `
50+
: `${subject} a better scoring scratch elsewhere. The improved score is ${match.score.toLocaleString("en-US")}${percentString}. `;
4951

5052
return (
5153
<DismissableBanner color={isMatch ? "#951fd9" : "#4273e1"}>
52-
{message}.{" "}
54+
{message}
5355
<Link href={scratchUrl(match)}>
54-
View {match.score === 0 ? "match" : "improvement"}
56+
View {isMatch ? "match" : "improvement"}
5557
</Link>
5658
</DismissableBanner>
5759
);

0 commit comments

Comments
 (0)