Skip to content

Commit

Permalink
- adding option to +rep people what used to be only for blacklisting
Browse files Browse the repository at this point in the history
- fixed sometimes dupe key on rcon-log-messages
  • Loading branch information
atomy committed Mar 2, 2024
1 parent 031f981 commit 2081b2a
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 deletions.
7 changes: 7 additions & 0 deletions src/renderer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ function Main() {
};

const addRconClientLogMessage = (logEntry: RconAppLogEntry) => {
const uniqueKey = () => {
const randomPart = Math.random().toString(36).substr(2, 9); // Using a random string
const timestampPart = new Date().getTime(); // Using a timestamp
return `${randomPart}-${timestampPart}`;
};
logEntry.Key = uniqueKey();

const updatedLogs = [...rconClientLogs, logEntry];

// Sort the array by logEntry.Timestamp in descending order
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/PlayerAddBlacklistAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function PlayerAddBlacklistAction({
>
<Box sx={style}>
<Typography id="modal-modal-title" variant="h6" component="h2">
Add player `{player.Name}` to blacklist
Add marker to player `{player.Name}`
</Typography>
<Typography component="h4">(Steam: {player.SteamID})</Typography>
<FormControl fullWidth>
Expand All @@ -70,6 +70,7 @@ export default function PlayerAddBlacklistAction({
<MenuItem value="bot">Bot</MenuItem>
<MenuItem value="cheat">Cheat</MenuItem>
<MenuItem value="warn">Warn</MenuItem>
<MenuItem value="plusrep">+Rep</MenuItem>
</Select>
<TextField
label="Reason"
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/PlayerTableComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ function Row(props: {
return '#ef9849';
}

if (['plusrep'].includes(row.PlayerWarningType)) {
return '#008000';
}

return 'transparent';
};

Expand Down
17 changes: 9 additions & 8 deletions src/renderer/PlayerWarning.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ export default function PlayerWarning(props: { player: PlayerInfo }) {
number={player.SteamBanDaysSinceLastBan}
/>
)) ||
(typeof player.PlayerWarningType !== 'undefined' && (
<img
width="20px"
title={`Type: '${player.PlayerWarningType}' Reason: '${player.PlayerWarningReason}'`}
src={Blacklist}
alt={`Type: '${player.PlayerWarningType}' Reason: '${player.PlayerWarningReason}'`}
/>
))
(player.PlayerWarningType &&
['cheat', 'bot', 'warn'].includes(player.PlayerWarningType) && (
<img
width="20px"
title={`Type: '${player.PlayerWarningType}' Reason: '${player.PlayerWarningReason}'`}
src={Blacklist}
alt={`Type: '${player.PlayerWarningType}' Reason: '${player.PlayerWarningReason}'`}
/>
))
);
}
1 change: 1 addition & 0 deletions src/renderer/RconAppLogEntry.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export interface RconAppLogEntry {
Timestamp: number;
Message: string;
Key: string;
}
2 changes: 1 addition & 1 deletion src/renderer/RconClientLogs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function RconClientLogs(props: { logs: RconAppLogEntry[] }) {
{logs.length > 0 ? (
<ul style={{ paddingLeft: '10px' }}>
{logs.map((logEntry) => (
<li key={logEntry.Timestamp}>{logEntry.Message}</li>
<li key={logEntry.Key}>{logEntry.Message}</li>
))}
</ul>
) : (
Expand Down

0 comments on commit 2081b2a

Please sign in to comment.