Merge pull request #137 from Pandipipas/fix-scoreboard-panel-reset-issues

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