Add player name visibility toggle and enhance display logic in lobby and results screens
Some checks failed
Publish Docker image / Push Docker image to Docker Hub (push) Failing after 3m43s
Some checks failed
Publish Docker image / Push Docker image to Docker Hub (push) Failing after 3m43s
This commit is contained in:
@ -3,6 +3,7 @@ import { useGame } from '../context/GameContext';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import { faTrophy, faHome, faRedo, faChartLine } from '@fortawesome/free-solid-svg-icons';
|
||||
import YouTubeEmbed from './YouTubeEmbed';
|
||||
import { getDisplayName } from '../utils/playerUtils';
|
||||
|
||||
const ResultsScreen = () => {
|
||||
const { lobby, currentPlayer, leaveLobby } = useGame();
|
||||
@ -73,6 +74,12 @@ const ResultsScreen = () => {
|
||||
return (match && match[2].length === 11) ? match[2] : null;
|
||||
}
|
||||
|
||||
// Find the submitter from the player list
|
||||
const findSubmitter = (submitterId) => {
|
||||
if (!lobby || !lobby.players) return null;
|
||||
return lobby.players.find(player => player.id === submitterId);
|
||||
};
|
||||
|
||||
if (!winner) {
|
||||
return (
|
||||
<div className="results-screen">
|
||||
@ -81,6 +88,9 @@ const ResultsScreen = () => {
|
||||
);
|
||||
}
|
||||
|
||||
// Find the player who submitted the winning song
|
||||
const submitter = findSubmitter(winner.submittedBy);
|
||||
|
||||
return (
|
||||
<div className="results-screen">
|
||||
<header>
|
||||
@ -91,7 +101,11 @@ const ResultsScreen = () => {
|
||||
<div className="winner-info">
|
||||
<h2>{winner.title}</h2>
|
||||
<h3>von {winner.artist}</h3>
|
||||
<p className="submitter">Eingereicht von: {winner.submittedByName}</p>
|
||||
<p className="submitter">
|
||||
Eingereicht von: {submitter
|
||||
? getDisplayName(submitter, lobby, currentPlayer)
|
||||
: (lobby?.settings?.hidePlayerNames ? 'Anonymer Spieler' : winner.submittedByName)}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{winnerVideoId ? (
|
||||
@ -129,6 +143,10 @@ const ResultsScreen = () => {
|
||||
const song1VideoId = getYouTubeId(battle.song1?.youtubeLink);
|
||||
const song2VideoId = battle.song2 ? getYouTubeId(battle.song2.youtubeLink) : null;
|
||||
|
||||
// Find the players who submitted the songs
|
||||
const song1Submitter = findSubmitter(battle.song1?.submittedBy);
|
||||
const song2Submitter = battle.song2 ? findSubmitter(battle.song2?.submittedBy) : null;
|
||||
|
||||
// Freilos-Runden behandeln
|
||||
const isByeRound = battle.bye === true || !battle.song2;
|
||||
|
||||
@ -144,6 +162,13 @@ const ResultsScreen = () => {
|
||||
<h5>{battle.song1.title}</h5>
|
||||
<p>{battle.song1.artist}</p>
|
||||
<span className="votes">{battle.song1Votes} Stimmen</span>
|
||||
{!lobby?.settings?.hidePlayerNames && (
|
||||
<span className="submitter">
|
||||
Eingereicht von: {song1Submitter
|
||||
? getDisplayName(song1Submitter, lobby, currentPlayer)
|
||||
: battle.song1?.submittedByName || 'Unbekannt'}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -155,6 +180,13 @@ const ResultsScreen = () => {
|
||||
<h5>{battle.song2.title}</h5>
|
||||
<p>{battle.song2.artist}</p>
|
||||
<span className="votes">{battle.song2Votes} Stimmen</span>
|
||||
{!lobby?.settings?.hidePlayerNames && (
|
||||
<span className="submitter">
|
||||
Eingereicht von: {song2Submitter
|
||||
? getDisplayName(song2Submitter, lobby, currentPlayer)
|
||||
: battle.song2?.submittedByName || 'Unbekannt'}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
|
Reference in New Issue
Block a user