Skip to content

Commit

Permalink
fix: Prevent racing condition to cause issue (#819)
Browse files Browse the repository at this point in the history
  • Loading branch information
felipetoffolo1 authored Jan 14, 2025
1 parent 4771a55 commit b34eb07
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/layouts/default/Default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ import { useRoute } from "vue-router";
const route = useRoute();
watch(
() => route.query.player,
(newActivePlayer) => {
// make sure it's retriggered when players array is populated
[() => route.query.player, () => Object.keys(api.players).length],
([newActivePlayer]) => {
if (!newActivePlayer) return;
const newPlayerString = newActivePlayer.toString().toLowerCase();
// newActivePlayer can be either player id or player name
const newPlayerId = Object.values(api.players).find((p) => {
return (
p.player_id === newActivePlayer ||
p.display_name.toLowerCase() ===
newActivePlayer.toString().toLowerCase()
p.player_id.toLowerCase() === newPlayerString ||
p.display_name.toLowerCase() === newPlayerString
);
})?.player_id;
Expand Down

0 comments on commit b34eb07

Please sign in to comment.