Fix scoreboard panel state resets across tabs

This commit is contained in:
Pandipipas
2026-02-25 13:57:09 +01:00
parent d69b294e0c
commit cecd08f3ac
@@ -394,6 +394,9 @@ const onRightBlur = () => {
const applyLeftPlayerData = (playerId: string) => { const applyLeftPlayerData = (playerId: string) => {
const player = playersStore.players[playerId]; const player = playersStore.players[playerId];
if (!player) {
return;
}
scoreboardStore.scoreboard.leftTeamOverride = player?.team ?? ''; scoreboardStore.scoreboard.leftTeamOverride = player?.team ?? '';
scoreboardStore.scoreboard.leftCountryOverride = player?.country ?? ''; scoreboardStore.scoreboard.leftCountryOverride = player?.country ?? '';
leftCountryInput.value = getCountryLabel(scoreboardStore.scoreboard.leftCountryOverride); leftCountryInput.value = getCountryLabel(scoreboardStore.scoreboard.leftCountryOverride);
@@ -401,6 +404,9 @@ const applyLeftPlayerData = (playerId: string) => {
const applyRightPlayerData = (playerId: string) => { const applyRightPlayerData = (playerId: string) => {
const player = playersStore.players[playerId]; const player = playersStore.players[playerId];
if (!player) {
return;
}
scoreboardStore.scoreboard.rightTeamOverride = player?.team ?? ''; scoreboardStore.scoreboard.rightTeamOverride = player?.team ?? '';
scoreboardStore.scoreboard.rightCountryOverride = player?.country ?? ''; scoreboardStore.scoreboard.rightCountryOverride = player?.country ?? '';
rightCountryInput.value = getCountryLabel(scoreboardStore.scoreboard.rightCountryOverride); rightCountryInput.value = getCountryLabel(scoreboardStore.scoreboard.rightCountryOverride);
@@ -662,9 +668,11 @@ watch(
rightCharacterOptions.value = options; rightCharacterOptions.value = options;
const allowed = new Set(options.map((option) => option.value)); const allowed = new Set(options.map((option) => option.value));
const savedCharacters = newGame ? charactersByGame.value[newGame] : undefined; const savedCharacters = newGame ? charactersByGame.value[newGame] : undefined;
const currentLeftCharacter = scoreboardStore.scoreboard.leftCharacter;
const currentRightCharacter = scoreboardStore.scoreboard.rightCharacter;
let nextLeftCharacter = savedCharacters?.leftCharacter ?? ''; let nextLeftCharacter = savedCharacters?.leftCharacter ?? currentLeftCharacter;
let nextRightCharacter = savedCharacters?.rightCharacter ?? ''; let nextRightCharacter = savedCharacters?.rightCharacter ?? currentRightCharacter;
if (!allowed.has(nextLeftCharacter)) { if (!allowed.has(nextLeftCharacter)) {
nextLeftCharacter = ''; nextLeftCharacter = '';
@@ -674,11 +682,15 @@ watch(
nextRightCharacter = ''; nextRightCharacter = '';
} }
if (!nextLeftCharacter && !nextRightCharacter) { if ((!nextLeftCharacter || !nextRightCharacter) && (!currentLeftCharacter || !currentRightCharacter)) {
const defaults = getDefaultCharactersByGame(newGame); const defaults = getDefaultCharactersByGame(newGame);
if (defaults) { if (defaults) {
nextLeftCharacter = allowed.has(defaults.leftCharacter) ? defaults.leftCharacter : ''; if (!nextLeftCharacter) {
nextRightCharacter = allowed.has(defaults.rightCharacter) ? defaults.rightCharacter : ''; nextLeftCharacter = allowed.has(defaults.leftCharacter) ? defaults.leftCharacter : '';
}
if (!nextRightCharacter) {
nextRightCharacter = allowed.has(defaults.rightCharacter) ? defaults.rightCharacter : '';
}
} }
} }