Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotate Players in ViewReport #2800

Merged
merged 3 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
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
20 changes: 20 additions & 0 deletions src/components/Player/Player.styl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,26 @@
margin-left: 0.1rem;
}

// Styling to support the "ShowPlayersInReportContext" context that we provide
.show-players-in-report & {
align-items: center;
&::after {
padding-left: 0.25rem;
width: 0.8rem;
font-family: 'FontAwesome';
font-size: 0.7rem;
content: "";
}
&.reported::after {
content: fa-exclamation-triangle-content;
themed color danger
}
&.reporter::after {
content: fa-bullhorn-content;
themed color supporter
}
}

&.with-flare {
align-items: baseline; // if we have flare, then we don't have presence indicator, and it's better to line up the baselines (looks better in chat)
}
Expand Down
18 changes: 18 additions & 0 deletions src/components/Player/Player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ export interface PlayerProperties {
forceShowRank?: boolean;
}

type ShowPlayersInReportContextType = {
reporter: player_cache.PlayerCacheEntry;
reported: player_cache.PlayerCacheEntry;
};

export const ShowPlayersInReportContext =
React.createContext<ShowPlayersInReportContextType | null>(null);

export function Player(props: PlayerProperties): JSX.Element {
const user = data.get("user");
const player_id: number =
Expand All @@ -99,6 +107,8 @@ export function Player(props: PlayerProperties): JSX.Element {
const base = player || historical;
const combined = base ? Object.assign({}, base, historical ? historical : {}) : null;

const viewReportContext = React.useContext(ShowPlayersInReportContext);

React.useEffect(() => {
if (!props.disableCacheUpdate) {
if (player?.id && player.id > 0) {
Expand Down Expand Up @@ -283,6 +293,14 @@ export function Player(props: PlayerProperties): JSX.Element {
main_attrs.className += " " + combined.ui_class;
}

if (viewReportContext && viewReportContext.reported.id === player_id) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels wrong, we shouldn't be spreading the context logic over to a generic component like Player I don't think. How about instead we put that context stuff up in the report code and then pass "reported" in for the ui_class for Player?

main_attrs.className += " reported";
}

if (viewReportContext && viewReportContext.reporter.id === player_id) {
main_attrs.className += " reporter";
}

if (player_id < 0) {
main_attrs.className += " guest";
}
Expand Down
2 changes: 2 additions & 0 deletions src/global_styl/font-awesome-hacks.styl
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ fa-circle-content="\f111";
fa-wrench-content="\f0ad";
fa-sort-asc-content="\f0de";
fa-sort-desc-content="\f0dd";
fa-bullhorn-content="\f0a1";
fa-exclamation-triangle-content="\f071";
fa-graduation-cap="\f19d";
11 changes: 2 additions & 9 deletions src/views/ReportsCenter/ReportedGame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -339,15 +339,8 @@ function GameOutcomeSummary({
<div>
{_("Player timed out:")}
<Player user={timedOutPlayer} />
{timedOutPlayer === reported_by
? pgettext(
"A note of surprise telling a moderator that the person who timed out is the reporter",
" (reporter!)",
)
: pgettext(
"A label next to a player name telling a moderator that a they are the one who was reported",
" (the reported player)",
)}
{timedOutPlayer === reported_by && "!!"}
{/* we are surprised if the reporter timed out */}
</div>
)}
{scoringAbandoned && <div>{_("Scoring abandoned by both players")}</div>}
Expand Down
Loading
Loading