mirror of
https://github.com/Pandipipas/scoreko-dev.git
synced 2026-06-06 03:32:06 +00:00
Merge pull request #137 from Pandipipas/fix-scoreboard-panel-reset-issues
Fix scoreboard state being reset when switching tabs
This commit is contained in:
@@ -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 : '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user