Skip to content

Commit a119a6c

Browse files
authored
bug: a finished match drops its Rounds tab and the maps it never played (#930)
1 parent d8e1cf5 commit a119a6c

2 files changed

Lines changed: 43 additions & 24 deletions

File tree

‎components/match/MatchMapSlots.vue‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { computed } from "vue";
33
import MatchMaps from "~/components/match/MatchMaps.vue";
44
import HeightSwap from "~/components/ui/transitions/HeightSwap.vue";
5-
import { e_match_status_enum } from "~/generated/zeus";
5+
import { e_match_map_status_enum, e_match_status_enum } from "~/generated/zeus";
66
77
// The match page's map cards: one slot per map of the series, a placeholder
88
// until the veto fills it.
@@ -28,7 +28,19 @@ const ENDED: string[] = [
2828
const mapSlots = computed<any[]>(() => {
2929
const maps = props.match.match_maps || [];
3030
const bestOf = props.match.options?.best_of;
31-
if (!bestOf || ENDED.includes(props.match.status)) {
31+
// Once the match is over, a map that was never played (the decider of a
32+
// 2-0) never will be, so only the played ones stay.
33+
if (ENDED.includes(props.match.status)) {
34+
return maps.filter(
35+
(map: any) =>
36+
map.rounds?.length > 0 ||
37+
[
38+
e_match_map_status_enum.Finished,
39+
e_match_map_status_enum.Surrendered,
40+
].includes(map.status),
41+
);
42+
}
43+
if (!bestOf) {
3244
return maps;
3345
}
3446
const slots: any[] = [];

‎components/match/MatchTabs.vue‎

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ const MatchLiveStreams = lazyPanel(
233233
<SelectItem value="scoreboard">
234234
{{ $t("match.tabs.scoreboard") }}
235235
</SelectItem>
236-
<SelectItem value="rounds">
236+
<SelectItem v-if="showRoundsTab" value="rounds">
237237
{{ $t("match.tabs.rounds") }}
238238
</SelectItem>
239239
<template v-if="!disableStats">
@@ -284,7 +284,7 @@ const MatchLiveStreams = lazyPanel(
284284
<TabsTrigger value="scoreboard">
285285
{{ $t("match.tabs.scoreboard") }}
286286
</TabsTrigger>
287-
<TabsTrigger value="rounds">
287+
<TabsTrigger v-if="showRoundsTab" value="rounds">
288288
{{ $t("match.tabs.rounds") }}
289289
</TabsTrigger>
290290
<template v-if="!disableStats">
@@ -543,8 +543,12 @@ const MatchLiveStreams = lazyPanel(
543543
</div>
544544
</Transition>
545545
</TabsContent>
546-
<TabsContent value="rounds" class="tab-panel-in mt-0">
547-
<MatchRoundsPanel :match="match" :match-map="roundsMap" />
546+
<TabsContent
547+
v-if="showRoundsTab"
548+
value="rounds"
549+
class="tab-panel-in mt-0"
550+
>
551+
<MatchRoundsPanel :match="match" :match-map="currentMap" />
548552
</TabsContent>
549553
<TabsContent value="economy" class="tab-panel-in mt-0">
550554
<div class="grid gap-4 max-w-[1500px]">
@@ -1178,17 +1182,13 @@ export default {
11781182
effectiveScoreboardLens() {
11791183
return this.disableStats ? "general" : this.scoreboardLens;
11801184
},
1181-
// The map the Rounds tab shows: the one picked above the tabs, else the
1182-
// map being played, else the last one with rounds.
1183-
roundsMap() {
1184-
const maps = this.match.match_maps ?? [];
1185-
if (this.activeMap) {
1186-
return maps.find((map: any) => map.id === this.activeMap!.id) ?? null;
1187-
}
1185+
// Rounds is for resets, so it only shows for the map being played; a
1186+
// finished map's rounds are on its own card.
1187+
showRoundsTab() {
11881188
return (
1189-
maps.find((map: any) => map.is_current_map) ??
1190-
[...maps].reverse().find((map: any) => map.rounds?.length) ??
1191-
null
1189+
this.match.status === e_match_status_enum.Live &&
1190+
!!this.currentMap &&
1191+
(!this.activeMap || this.activeMap.id === this.currentMap.id)
11921192
);
11931193
},
11941194
isOpsTabActive() {
@@ -1395,7 +1395,11 @@ export default {
13951395
return true;
13961396
},
13971397
availableMatchTabs() {
1398-
const tabs = ["scoreboard", "rounds"];
1398+
const tabs = ["scoreboard"];
1399+
1400+
if (this.showRoundsTab) {
1401+
tabs.push("rounds");
1402+
}
13991403
14001404
if (!this.disableStats) {
14011405
tabs.push("economy");
@@ -1438,14 +1442,17 @@ export default {
14381442
if (this.activeMap && this.activeMap.id !== current?.id) {
14391443
this.$emit("clear-active-map");
14401444
}
1441-
this.activeTab = "rounds";
1445+
// Rounds only exists once a finished map's pick has cleared.
14421446
void this.$nextTick(() => {
1443-
const reduce = window.matchMedia?.(
1444-
"(prefers-reduced-motion: reduce)",
1445-
).matches;
1446-
(this.$el as HTMLElement | undefined)?.scrollIntoView?.({
1447-
behavior: reduce ? "auto" : "smooth",
1448-
block: "start",
1447+
this.activeTab = "rounds";
1448+
void this.$nextTick(() => {
1449+
const reduce = window.matchMedia?.(
1450+
"(prefers-reduced-motion: reduce)",
1451+
).matches;
1452+
(this.$el as HTMLElement | undefined)?.scrollIntoView?.({
1453+
behavior: reduce ? "auto" : "smooth",
1454+
block: "start",
1455+
});
14491456
});
14501457
});
14511458
},

0 commit comments

Comments
 (0)