diff --git a/src/dashboard/scoreko-dev/views/Players.vue b/src/dashboard/scoreko-dev/views/Players.vue index 3ed16ed..cc9ccba 100644 --- a/src/dashboard/scoreko-dev/views/Players.vue +++ b/src/dashboard/scoreko-dev/views/Players.vue @@ -37,7 +37,6 @@ const STARTGG_TEMP_FALLBACK_DURATION_SECONDS = 12 * 60 * 60; interface TemporaryStartGGPlayerMeta { expiresAt: number; tournamentSlug: string; - tournamentName: string; } type TemporaryStartGGPlayersMap = Record; @@ -103,7 +102,7 @@ const loadingTournaments = ref(false); const tournamentsError = ref(''); const isImportDialogOpen = ref(false); const loadingTournamentPlayers = ref(false); -const selectedTournament = ref(null); +const importingTournament = ref(null); const startGGPlayers = ref([]); const selectedStartGGPlayerIds = ref([]); const selectedTournamentSlug = ref(''); @@ -153,14 +152,12 @@ const loadTemporaryStartGGPlayers = (): TemporaryStartGGPlayersMap => { const candidate = value as Record; const expiresAt = Number(candidate.expiresAt); const tournamentSlug = String(candidate.tournamentSlug || '').trim(); - const tournamentName = String(candidate.tournamentName || '').trim(); if (!Number.isFinite(expiresAt) || expiresAt <= 0 || !tournamentSlug) { return; } result[playerId] = { expiresAt, tournamentSlug, - tournamentName, }; }); @@ -190,6 +187,7 @@ watch(tournamentOptions, (value) => { const selectedTournamentOption = computed(() => recentTournaments.value.find((item) => item.slug === selectedTournamentSlug.value) ?? null, ); +const canImportSelectedTournament = computed(() => Boolean(selectedTournamentOption.value)); const filterTournaments = (value: string, update: (callback: () => void) => void) => { update(() => { @@ -330,7 +328,7 @@ const loadRecentTournaments = async () => { }; const openStartGGImportDialog = async (tournament: StartGGTournament) => { - selectedTournament.value = tournament; + importingTournament.value = tournament; isImportDialogOpen.value = true; loadingTournamentPlayers.value = true; selectedStartGGPlayerIds.value = []; @@ -368,7 +366,7 @@ const importSelectedStartGGPlayers = () => { ); const nextMeta = { ...temporaryStartGGPlayers.value }; - const tournament = selectedTournament.value; + const tournament = importingTournament.value; const fallbackEndAt = (tournament?.startAt ?? Math.floor(Date.now() / 1000)) + STARTGG_TEMP_FALLBACK_DURATION_SECONDS; const expiresAt = tournament?.endAt ?? fallbackEndAt; @@ -385,7 +383,6 @@ const importSelectedStartGGPlayers = () => { nextMeta[player.id] = { expiresAt, tournamentSlug: tournament.slug, - tournamentName: tournament.name, }; } }); @@ -642,7 +639,7 @@ onBeforeUnmount(() => {
{
- Importar desde {{ selectedTournament?.name || 'start.gg' }} + Importar desde {{ importingTournament?.name || 'start.gg' }}
@@ -817,10 +814,6 @@ onBeforeUnmount(() => { width: min(720px, 90vw); } -.startgg-tournaments-list { - max-height: 280px; - overflow: auto; -} .players-underlined-field :deep(.q-field__control) { min-height: 28px; diff --git a/src/extension/startgg.ts b/src/extension/startgg.ts index e3e0a47..1a06786 100644 --- a/src/extension/startgg.ts +++ b/src/extension/startgg.ts @@ -48,7 +48,6 @@ interface OAuthConfig { interface OAuthSession { sessionId: string; state: string; - createdAt: number; expiresAt: number; status: 'pending' | 'completed' | 'error' | 'expired'; token?: string; @@ -91,8 +90,9 @@ const requestStartGG = async (query: string, variables: Record country.code.toUpperCase())); -const countryByName = new Map(getData().map((country: CountryRecord) => [country.name.toLowerCase(), country.code.toUpperCase()])); +const countries = getData(); +const countryByCode = new Set(countries.map((country: CountryRecord) => country.code.toUpperCase())); +const countryByName = new Map(countries.map((country: CountryRecord) => [country.name.toLowerCase(), country.code.toUpperCase()])); const resolveCountryCodeFromStartGG = (country: string | null | undefined): string => { const raw = (country || '').trim(); @@ -346,12 +346,10 @@ nodecg.listenFor('startgg:createOAuthSession', async (_payload: unknown, ack) => const sessionId = randomUUID(); const state = randomUUID(); - const now = Date.now(); const session: OAuthSession = { sessionId, state, - createdAt: now, - expiresAt: now + STARTGG_OAUTH_SESSION_TTL_MS, + expiresAt: Date.now() + STARTGG_OAUTH_SESSION_TTL_MS, status: 'pending', }; oauthSessions.set(sessionId, session);