mirror of
https://github.com/ershisan99/www.git
synced 2025-12-17 12:34:17 +00:00
only update the changed user's info instead of both
This commit is contained in:
@@ -131,49 +131,34 @@ export function ObsControlPanelClient() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isConnected) return
|
if (!isConnected) return
|
||||||
if (player1Data?.username) {
|
|
||||||
|
if (player1Data) {
|
||||||
form.setValue('player1Name', player1Data.username)
|
form.setValue('player1Name', player1Data.username)
|
||||||
}
|
|
||||||
if (player2Data?.username) {
|
|
||||||
form.setValue('player2Name', player2Data.username)
|
|
||||||
}
|
|
||||||
if (player1Data?.mmr) {
|
|
||||||
form.setValue('player1Mmr', player1Data.mmr.toString())
|
form.setValue('player1Mmr', player1Data.mmr.toString())
|
||||||
}
|
|
||||||
if (player2Data?.mmr) {
|
|
||||||
form.setValue('player2Mmr', player2Data.mmr.toString())
|
|
||||||
}
|
|
||||||
if (player1Data?.games) {
|
|
||||||
form.setValue('player1Games', player1Data.games.toString())
|
form.setValue('player1Games', player1Data.games.toString())
|
||||||
}
|
|
||||||
if (player2Data?.games) {
|
|
||||||
form.setValue('player2Games', player2Data.games.toString())
|
|
||||||
}
|
|
||||||
if (player1Data?.wins) {
|
|
||||||
form.setValue('player1Wins', player1Data.wins.toString())
|
form.setValue('player1Wins', player1Data.wins.toString())
|
||||||
}
|
|
||||||
if (player2Data?.wins) {
|
|
||||||
form.setValue('player2Wins', player2Data.wins.toString())
|
|
||||||
}
|
|
||||||
if (player1Data?.losses) {
|
|
||||||
form.setValue('player1Losses', player1Data.losses.toString())
|
form.setValue('player1Losses', player1Data.losses.toString())
|
||||||
}
|
|
||||||
if (player2Data?.losses) {
|
|
||||||
form.setValue('player2Losses', player2Data.losses.toString())
|
|
||||||
}
|
|
||||||
if (player1Data?.rank) {
|
|
||||||
form.setValue('player1Rank', player1Data.rank.toString())
|
form.setValue('player1Rank', player1Data.rank.toString())
|
||||||
}
|
|
||||||
if (player2Data?.rank) {
|
|
||||||
form.setValue('player2Rank', player2Data.rank.toString())
|
|
||||||
}
|
|
||||||
if (player1Data?.winRate) {
|
|
||||||
form.setValue('player1WinRate', `${player1Data.winRate.toString()}%`)
|
form.setValue('player1WinRate', `${player1Data.winRate.toString()}%`)
|
||||||
}
|
}
|
||||||
if (player2Data?.winRate) {
|
}, [player1Data, isConnected])
|
||||||
form.setValue('player2WinRate', `${player2Data.winRate.toString()}%`)
|
|
||||||
|
// Effect to update Player 2 form fields when player2 selection or data changes
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isConnected) return
|
||||||
|
|
||||||
|
if (player2Data) {
|
||||||
|
if (player2Data) {
|
||||||
|
form.setValue('player2Name', player2Data.username)
|
||||||
|
form.setValue('player2Mmr', player2Data.mmr.toString())
|
||||||
|
form.setValue('player2Games', player2Data.games.toString())
|
||||||
|
form.setValue('player2Wins', player2Data.wins.toString())
|
||||||
|
form.setValue('player2Losses', player2Data.losses.toString())
|
||||||
|
form.setValue('player2Rank', player2Data.rank.toString())
|
||||||
|
form.setValue('player2WinRate', `${player2Data.winRate.toString()}%`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [player1Data, player2Data, isConnected])
|
}, [player2Data, isConnected])
|
||||||
|
|
||||||
const [mappings] = useLocalStorage<FieldMapping[]>('obs-field-mappings', [])
|
const [mappings] = useLocalStorage<FieldMapping[]>('obs-field-mappings', [])
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export function getPlayerData(
|
|||||||
const meaningful_games = games_played - ties
|
const meaningful_games = games_played - ties
|
||||||
|
|
||||||
return {
|
return {
|
||||||
username: currentName,
|
username: currentName ?? 'Unknown',
|
||||||
games: games_played,
|
games: games_played,
|
||||||
meaningful_games,
|
meaningful_games,
|
||||||
wins,
|
wins,
|
||||||
|
|||||||
Reference in New Issue
Block a user