fix user turn issue in infopanel

This commit is contained in:
Halit Aksoy 2022-07-09 13:12:22 +03:00
parent eb1a51c41f
commit 6f96842a87

View File

@ -41,10 +41,12 @@ function getInfoPanelTextByGameState(params: {
} }
return context.texts.GameEnded + " " + whoWon; return context.texts.GameEnded + " " + whoWon;
} else { } else {
return game?.checkIsPlayerTurn(userKey) if (game) {
return game.checkIsPlayerTurn(userKey)
? context.texts.YourTurn ? context.texts.YourTurn
: context.texts.OpponentTurn; : context.texts.OpponentTurn;
} }
}
return undefined; return undefined;
} }
@ -90,20 +92,25 @@ const InfoPanel: FunctionComponent<{
context.themeManager.theme.primary, context.themeManager.theme.primary,
context.themeManager.theme.primaryLight context.themeManager.theme.primaryLight
); );
return ( const text = getInfoPanelTextByGameState({
<InfoPanelContainer context={context} color={containerColor}>
<h4 style={{ margin: "0", color: textColor }}>
{getInfoPanelTextByGameState({
context, context,
game, game,
crashMessage, crashMessage,
userKey, userKey,
userKeyWhoLeave, userKeyWhoLeave,
searchingOpponent, searchingOpponent,
})} });
if (text) {
return (
<InfoPanelContainer context={context} color={containerColor}>
<h4 style={{ margin: "0", color: textColor }}>
{text}
</h4> </h4>
</InfoPanelContainer> </InfoPanelContainer>
); );
} else {
return (<div></div>)
}
}; };
export default InfoPanel; export default InfoPanel;