@@ -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