mirror of
https://github.com/Pandipipas/scoreko-dev.git
synced 2026-06-06 03:32:06 +00:00
Fix scoreboard panel state resets across tabs
This commit is contained in:
@@ -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 : '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user