@maestro_io/maestro-web-sdk 2.1.3 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/MaestroEventDelegate.d.ts +1 -0
- package/dist/components/atoms/SvgIcon/Icon.d.ts +0 -2
- package/dist/components/core/ScrollableContainer/ScrollableContainer.d.ts +3 -1
- package/dist/external/spatial-navigation/spatialNavigation.d.ts +1 -1
- package/dist/interfaces/IMaestroEvent.d.ts +14 -0
- package/dist/interfaces/IMaestroEventDelegate.d.ts +19 -6
- package/dist/maestro-web-sdk.umd.js +3 -3
- package/dist/maestro-web-sdk.umd.js.map +1 -1
- package/dist/models/IPanel.d.ts +1 -2
- package/dist/modules/stats/interfaces/IStats.d.ts +38 -12
- package/dist/modules/stats/mocks.d.ts +0 -80
- package/dist/modules/stats/utils/driveSummaryUtils.d.ts +18 -0
- package/dist/modules/stats/view/ActiveAthletes/ActiveAthletes.d.ts +6 -19
- package/dist/modules/stats/view/DriveSummary/DrivePlayCard.d.ts +26 -0
- package/dist/modules/stats/view/DriveSummary/DriveSummary.d.ts +24 -0
- package/dist/modules/stats/view/DriveSummary/index.d.ts +2 -0
- package/dist/modules/stats/view/GameLeaders/GameLeaders.d.ts +15 -4
- package/dist/modules/stats/view/MatchPredictor/MatchPredictorView.d.ts +13 -48
- package/dist/modules/stats/view/RecentGames/RecentGames.d.ts +10 -21
- package/dist/modules/stats/view/StatsItemView.d.ts +19 -0
- package/dist/modules/stats/view/StatsView.d.ts +3 -3
- package/dist/modules/stats/view/TeamStats/TeamStatsView.d.ts +2 -4
- package/dist/modules/stats/view/Teams/Teams.d.ts +10 -26
- package/dist/modules/stats/view/WinProbability/WinProbability.d.ts +10 -21
- package/dist/modules/stats/view-model/StatsViewModel.d.ts +149 -5
- package/package.json +1 -1
- package/dist/MaestroEventDelegate.js +0 -60
- package/dist/components/atoms/BaseButton/BaseButton.js +0 -11
- package/dist/components/atoms/BaseButton/index.js +0 -2
- package/dist/components/atoms/Image/index.js +0 -30
- package/dist/components/atoms/Rive/index.js +0 -53
- package/dist/components/atoms/SvgIcon/BetGeneralIcon.js +0 -9
- package/dist/components/atoms/SvgIcon/BetsIcon.js +0 -11
- package/dist/components/atoms/SvgIcon/BetsWarningIcon.js +0 -11
- package/dist/components/atoms/SvgIcon/CheckmarkIcon.js +0 -6
- package/dist/components/atoms/SvgIcon/CollapseIcon.js +0 -6
- package/dist/components/atoms/SvgIcon/ExpandIcon.js +0 -6
- package/dist/components/atoms/SvgIcon/FantasyIcon.d.ts +0 -6
- package/dist/components/atoms/SvgIcon/FantasyIcon.js +0 -8
- package/dist/components/atoms/SvgIcon/FlameIcon.js +0 -11
- package/dist/components/atoms/SvgIcon/Icon.js +0 -42
- package/dist/components/atoms/SvgIcon/KeyPlaysIcon.js +0 -10
- package/dist/components/atoms/SvgIcon/MobilePhoneIcon.js +0 -11
- package/dist/components/atoms/SvgIcon/PlayIcon.js +0 -8
- package/dist/components/atoms/SvgIcon/StatsIcon.js +0 -12
- package/dist/components/atoms/SvgIcon/TimesIcon.js +0 -6
- package/dist/components/atoms/SvgIcon/WarningIcon.js +0 -8
- package/dist/components/atoms/SvgIcon/index.js +0 -2
- package/dist/components/core/App/App.js +0 -41
- package/dist/components/core/App/index.js +0 -2
- package/dist/components/core/OverlayContainer.js +0 -58
- package/dist/components/core/PanelManager/PanelManager.js +0 -80
- package/dist/components/core/PanelManager/index.js +0 -2
- package/dist/components/core/ScrollableContainer/FocusableItem.js +0 -38
- package/dist/components/core/ScrollableContainer/ScrollableContainer.js +0 -166
- package/dist/components/core/ScrollableContainer/index.js +0 -2
- package/dist/components/molecules/ActionButton/ActionButton.js +0 -10
- package/dist/components/molecules/ActionButton/index.js +0 -2
- package/dist/components/molecules/Overlay/Overlay.js +0 -139
- package/dist/components/molecules/Overlay/index.js +0 -2
- package/dist/components/molecules/PanelNavButton/PanelNavButton.js +0 -40
- package/dist/components/molecules/PanelNavButton/index.js +0 -2
- package/dist/components/molecules/SegmentButton/SegmentButton.js +0 -10
- package/dist/components/molecules/SegmentButton/index.js +0 -2
- package/dist/components/molecules/WatchButton/WatchButton.js +0 -15
- package/dist/components/molecules/WatchButton/index.js +0 -2
- package/dist/components/organisms/PanelNavigation/PanelNavigation.js +0 -71
- package/dist/components/organisms/PanelNavigation/index.js +0 -2
- package/dist/components/organisms/SegmentController/SegmentController.js +0 -68
- package/dist/components/organisms/SegmentController/index.js +0 -2
- package/dist/external/AxiosNetworkClient.js +0 -83
- package/dist/external/LocalStorageCacheManager.js +0 -213
- package/dist/external/ReactRenderer.js +0 -86
- package/dist/external/mocks/MockExternalNetworkClient.js +0 -161
- package/dist/external/ports/cacheManager.js +0 -1
- package/dist/external/ports/networkClient.js +0 -1
- package/dist/external/ports/renderer.js +0 -1
- package/dist/external/spatial-navigation/index.js +0 -3
- package/dist/external/spatial-navigation/measureLayout.js +0 -30
- package/dist/external/spatial-navigation/spatialNavigation.js +0 -864
- package/dist/external/spatial-navigation/utils.js +0 -6
- package/dist/external/spatial-navigation/visualDebugger.js +0 -76
- package/dist/external/spatial-navigation/withFocusable.js +0 -245
- package/dist/helpers/Observable.js +0 -37
- package/dist/helpers/deliver-focus.d.ts +0 -5
- package/dist/helpers/deliver-focus.js +0 -12
- package/dist/index.js +0 -192
- package/dist/interfaces/IMaestroEvent.js +0 -6
- package/dist/interfaces/IMaestroEventDelegate.js +0 -1
- package/dist/interfaces/IMaestroManager.js +0 -1
- package/dist/models/IModel.js +0 -1
- package/dist/models/IPanel.js +0 -53
- package/dist/models/ITheme.js +0 -20
- package/dist/models/IWinningBet.js +0 -1
- package/dist/modules/bets/interfaces/IBets.js +0 -1
- package/dist/modules/bets/mocks.js +0 -572
- package/dist/modules/bets/view/BetsView.js +0 -116
- package/dist/modules/bets/view/HotProps/HotPropsView.js +0 -139
- package/dist/modules/bets/view/SixPack/SixPackView.js +0 -103
- package/dist/modules/bets/view/TabLoadFailureView.js +0 -12
- package/dist/modules/bets/view/UserBets/BetResult/BetResult.js +0 -6
- package/dist/modules/bets/view/UserBets/BetsCard/BetsCard.js +0 -122
- package/dist/modules/bets/view/UserBets/BetsCard/BetsCardEvent.js +0 -34
- package/dist/modules/bets/view/UserBets/BetsCard/BetsCardFooter.js +0 -22
- package/dist/modules/bets/view/UserBets/Boost/Boost.js +0 -6
- package/dist/modules/bets/view/UserBets/OutcomeBadge/OutcomeBadge.js +0 -9
- package/dist/modules/bets/view/UserBets/Parlay/Parlay.js +0 -13
- package/dist/modules/bets/view/UserBets/Straight/Straight.js +0 -6
- package/dist/modules/bets/view/UserBets/Teaser/Teaser.js +0 -13
- package/dist/modules/bets/view/UserBets/UserBetsView.js +0 -114
- package/dist/modules/bets/view/components/Bet/Bet.js +0 -32
- package/dist/modules/bets/view/components/BetPill/BetPill.js +0 -6
- package/dist/modules/bets/view/components/BetsCard/BetsCard.js +0 -15
- package/dist/modules/bets/view/components/BetsCard/BetsCardHeader.js +0 -20
- package/dist/modules/bets/view/components/GamblingDisclaimer/GamblingDisclaimer.js +0 -14
- package/dist/modules/bets/view/components/LocationWarning/LocationWarning.js +0 -16
- package/dist/modules/bets/view/components/PromoCodeBanner/PromoCodeBanner.js +0 -63
- package/dist/modules/bets/view/components/PromoCodeBanner/index.js +0 -1
- package/dist/modules/bets/view-model/BetsViewModel.js +0 -767
- package/dist/modules/key-plays/constants.js +0 -292
- package/dist/modules/key-plays/interfaces/IKeyPlays.js +0 -14
- package/dist/modules/key-plays/interfaces/IKeyPlaysResponse.js +0 -1
- package/dist/modules/key-plays/view/KeyPlayCardScoreTagView.js +0 -13
- package/dist/modules/key-plays/view/KeyPlayCardView.js +0 -120
- package/dist/modules/key-plays/view/KeyPlayErrorStateView.js +0 -58
- package/dist/modules/key-plays/view/KeyPlaysView.js +0 -166
- package/dist/modules/key-plays/view-model/KeyPlaysViewModel.js +0 -182
- package/dist/modules/stats/interfaces/IStats.js +0 -1
- package/dist/modules/stats/mocks.js +0 -686
- package/dist/modules/stats/utils/renderTeamStatistic.js +0 -16
- package/dist/modules/stats/utils.js +0 -62
- package/dist/modules/stats/view/ActiveAthletes/ActiveAthletes.js +0 -78
- package/dist/modules/stats/view/ActiveAthletes/CollapsedAthletes/CollapsedAthletes.js +0 -27
- package/dist/modules/stats/view/ActiveAthletes/ExpandedAthletes/ExpandedAthletes.js +0 -15
- package/dist/modules/stats/view/ActiveAthletes/index.js +0 -2
- package/dist/modules/stats/view/GameLeaders/GameLeaders.js +0 -9
- package/dist/modules/stats/view/GameLeaders/index.js +0 -2
- package/dist/modules/stats/view/MatchPredictor/DonutChart/DonutChart.js +0 -55
- package/dist/modules/stats/view/MatchPredictor/DonutChart/index.js +0 -1
- package/dist/modules/stats/view/MatchPredictor/MatchPredictorView.js +0 -66
- package/dist/modules/stats/view/MatchPredictor/index.js +0 -2
- package/dist/modules/stats/view/RecentGames/RecentGames.js +0 -22
- package/dist/modules/stats/view/RecentGames/index.js +0 -2
- package/dist/modules/stats/view/StatsQRCode/StatsQRCodeView.js +0 -38
- package/dist/modules/stats/view/StatsQRCode/index.js +0 -1
- package/dist/modules/stats/view/StatsView.js +0 -107
- package/dist/modules/stats/view/TeamStats/TeamStatsView.js +0 -69
- package/dist/modules/stats/view/TeamStats/index.js +0 -1
- package/dist/modules/stats/view/Teams/StatsCarousel.js +0 -14
- package/dist/modules/stats/view/Teams/StatsProgressBar.js +0 -18
- package/dist/modules/stats/view/Teams/Teams.js +0 -42
- package/dist/modules/stats/view/Teams/index.js +0 -2
- package/dist/modules/stats/view/WinProbability/WinProbability.js +0 -27
- package/dist/modules/stats/view/WinProbability/index.js +0 -2
- package/dist/modules/stats/view/components/AthletesStatistics/AthletesStatistics.js +0 -29
- package/dist/modules/stats/view/components/AthletesStatistics/StatisticTable.js +0 -12
- package/dist/modules/stats/view/components/AthletesStatistics/index.js +0 -2
- package/dist/modules/stats/view/index.js +0 -2
- package/dist/modules/stats/view-model/StatsViewModel.js +0 -90
- package/dist/services/BetsService.js +0 -102
- package/dist/services/NetworkManager/NetworkManager.js +0 -410
- package/dist/services/NetworkManager/errors.js +0 -45
- package/dist/services/StatsService.js +0 -68
- package/dist/services/ThemeManager/constants.js +0 -47
- package/dist/test-polyfills.js +0 -15
- package/dist/types/OverlayTypes.js +0 -4
- package/dist/view-models/MaestroEventViewModel.js +0 -168
- package/dist/view-models/OverlayViewModel.js +0 -222
- package/dist/view-models/PanelManagerViewModel.js +0 -80
- package/dist/view-models/ViewModel.js +0 -32
- package/dist/view-models/index.js +0 -59
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import React, { Component } from 'react';
|
|
2
|
-
import KeyPlayCardView from './KeyPlayCardView';
|
|
3
|
-
import './KeyPlaysView.styles.css';
|
|
4
|
-
import KeyPlayErrorStateView from './KeyPlayErrorStateView';
|
|
5
|
-
import SDK from '@/index';
|
|
6
|
-
import ScrollableContainer from '@/components/core/ScrollableContainer';
|
|
7
|
-
const STICKY_HEADER_HEIGHT = 32;
|
|
8
|
-
export class KeyPlays extends Component {
|
|
9
|
-
constructor(props) {
|
|
10
|
-
super(props);
|
|
11
|
-
Object.defineProperty(this, "container", {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
configurable: true,
|
|
14
|
-
writable: true,
|
|
15
|
-
value: null
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(this, "playbackProgressUnsub", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
configurable: true,
|
|
20
|
-
writable: true,
|
|
21
|
-
value: null
|
|
22
|
-
});
|
|
23
|
-
Object.defineProperty(this, "playbackIndexUnsub", {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
configurable: true,
|
|
26
|
-
writable: true,
|
|
27
|
-
value: null
|
|
28
|
-
});
|
|
29
|
-
Object.defineProperty(this, "itemsUnsub", {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
configurable: true,
|
|
32
|
-
writable: true,
|
|
33
|
-
value: null
|
|
34
|
-
});
|
|
35
|
-
Object.defineProperty(this, "vm", {
|
|
36
|
-
enumerable: true,
|
|
37
|
-
configurable: true,
|
|
38
|
-
writable: true,
|
|
39
|
-
value: void 0
|
|
40
|
-
});
|
|
41
|
-
Object.defineProperty(this, "handlePlayClip", {
|
|
42
|
-
enumerable: true,
|
|
43
|
-
configurable: true,
|
|
44
|
-
writable: true,
|
|
45
|
-
value: (index) => async () => {
|
|
46
|
-
await this.vm.playKeyPlay(index);
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
this.vm = SDK.getMaestroEventViewModel().keyPlaysViewModel;
|
|
50
|
-
const rawSections = this.vm.items.value;
|
|
51
|
-
this.state = {
|
|
52
|
-
scrollableContainer: null,
|
|
53
|
-
playbackProgress: this.vm.currentClipPlaybackProgress.value ?? null,
|
|
54
|
-
playbackIndex: this.vm.currentlyPlayingClipIndex.value ?? null,
|
|
55
|
-
items: rawSections.map((section) => ({
|
|
56
|
-
title: section.title,
|
|
57
|
-
items: section.items.map((item) => ({
|
|
58
|
-
id: item.id,
|
|
59
|
-
clipID: item.clipID,
|
|
60
|
-
awayTeamScore: item.awayTeamScore,
|
|
61
|
-
homeTeamScore: item.homeTeamScore,
|
|
62
|
-
awayTeamName: item.awayTeamName,
|
|
63
|
-
homeTeamName: item.homeTeamName,
|
|
64
|
-
description: item.description,
|
|
65
|
-
playerImageUrl: item.playerImageUrl || '',
|
|
66
|
-
teamImageUrl: item.teamImageUrl || '',
|
|
67
|
-
thumbnailImageUrl: item.thumbnailImageUrl || '',
|
|
68
|
-
})),
|
|
69
|
-
})),
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
componentDidMount() {
|
|
73
|
-
this.playbackProgressUnsub = this.vm.currentClipPlaybackProgress.subscribe((value) => {
|
|
74
|
-
this.setState({ playbackProgress: value ?? null });
|
|
75
|
-
});
|
|
76
|
-
this.playbackIndexUnsub = this.vm.currentlyPlayingClipIndex.subscribe((value) => {
|
|
77
|
-
this.setState({ playbackIndex: value ?? null });
|
|
78
|
-
});
|
|
79
|
-
this.itemsUnsub = this.vm.items.subscribe((rawSections) => {
|
|
80
|
-
this.setState({
|
|
81
|
-
items: rawSections.map((section) => ({
|
|
82
|
-
title: section.title,
|
|
83
|
-
items: section.items.map((item) => ({
|
|
84
|
-
id: item.id,
|
|
85
|
-
clipID: item.clipID,
|
|
86
|
-
awayTeamScore: item.awayTeamScore,
|
|
87
|
-
homeTeamScore: item.homeTeamScore,
|
|
88
|
-
awayTeamName: item.awayTeamName,
|
|
89
|
-
homeTeamName: item.homeTeamName,
|
|
90
|
-
description: item.description,
|
|
91
|
-
playerImageUrl: item.playerImageUrl || '',
|
|
92
|
-
teamImageUrl: item.teamImageUrl || '',
|
|
93
|
-
thumbnailImageUrl: item.thumbnailImageUrl || '',
|
|
94
|
-
})),
|
|
95
|
-
})),
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
this.setState({
|
|
99
|
-
scrollableContainer: this.container,
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
componentWillUnmount() {
|
|
103
|
-
this.playbackProgressUnsub && this.playbackProgressUnsub();
|
|
104
|
-
this.playbackIndexUnsub && this.playbackIndexUnsub();
|
|
105
|
-
this.itemsUnsub && this.itemsUnsub();
|
|
106
|
-
}
|
|
107
|
-
render() {
|
|
108
|
-
const { playbackProgress, playbackIndex, items, scrollableContainer, } = this.state;
|
|
109
|
-
return (React.createElement(ScrollableContainer, { scrollableContainerRef: scrollableContainer, containerTopOffset: STICKY_HEADER_HEIGHT },
|
|
110
|
-
React.createElement("div", { ref: (el) => {
|
|
111
|
-
this.container = el;
|
|
112
|
-
}, className: "key-plays-view" },
|
|
113
|
-
items.map((section, sectionIndex) => (React.createElement("div", { key: `section-${sectionIndex}`, className: "key-plays-section" },
|
|
114
|
-
React.createElement("h3", { className: "key-plays-section-title T10" }, section.title),
|
|
115
|
-
React.createElement("div", { className: "key-plays-section-items" }, section.items.map((item) => {
|
|
116
|
-
const absoluteIndex = this.vm.allItems.findIndex((vmItem) => vmItem.id === item.id);
|
|
117
|
-
return (React.createElement(KeyPlayCardView, { key: item.id, id: item.id, clipID: item.clipID, description: item.description, awayTeamName: item.awayTeamName, homeTeamName: item.homeTeamName, awayTeamScore: item.awayTeamScore, homeTeamScore: item.homeTeamScore, playerImageUrl: item.playerImageUrl, teamImageUrl: item.teamImageUrl, thumbnailImageUrl: item.thumbnailImageUrl, isPlaying: this.vm.isCurrentlyPlaying(absoluteIndex), isScoring: Boolean(item.awayTeamScore && item.homeTeamScore), playbackProgress: absoluteIndex === playbackIndex
|
|
118
|
-
? playbackProgress
|
|
119
|
-
: null, onEnterPress: this.handlePlayClip(absoluteIndex) }));
|
|
120
|
-
}))))),
|
|
121
|
-
React.createElement("div", { className: "key-plays-bottom-padding" }))));
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
export default class KeyPlaysWithErrorState extends Component {
|
|
125
|
-
constructor(props) {
|
|
126
|
-
super(props);
|
|
127
|
-
Object.defineProperty(this, "errorStateUnsub", {
|
|
128
|
-
enumerable: true,
|
|
129
|
-
configurable: true,
|
|
130
|
-
writable: true,
|
|
131
|
-
value: null
|
|
132
|
-
});
|
|
133
|
-
Object.defineProperty(this, "vm", {
|
|
134
|
-
enumerable: true,
|
|
135
|
-
configurable: true,
|
|
136
|
-
writable: true,
|
|
137
|
-
value: void 0
|
|
138
|
-
});
|
|
139
|
-
Object.defineProperty(this, "handleRetry", {
|
|
140
|
-
enumerable: true,
|
|
141
|
-
configurable: true,
|
|
142
|
-
writable: true,
|
|
143
|
-
value: async () => {
|
|
144
|
-
await this.vm.userRequestedNewKeyPlaysData();
|
|
145
|
-
SDK.getMaestroEventViewModel().navigation.setFocus('PANEL_NAV_BUTTON_0');
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
this.vm = SDK.getMaestroEventViewModel().keyPlaysViewModel;
|
|
149
|
-
this.state = { errorState: this.vm.errorState.value };
|
|
150
|
-
}
|
|
151
|
-
componentDidMount() {
|
|
152
|
-
this.errorStateUnsub = this.vm.errorState.subscribe((value) => {
|
|
153
|
-
this.setState({ errorState: value });
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
componentWillUnmount() {
|
|
157
|
-
this.errorStateUnsub && this.errorStateUnsub();
|
|
158
|
-
}
|
|
159
|
-
render() {
|
|
160
|
-
const { errorState } = this.state;
|
|
161
|
-
if (errorState) {
|
|
162
|
-
return (React.createElement(KeyPlayErrorStateView, { errorState: errorState, onRetry: this.handleRetry }));
|
|
163
|
-
}
|
|
164
|
-
return React.createElement(KeyPlays, null);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import SDK from '@/index';
|
|
2
|
-
import { Observable } from '@/helpers/Observable';
|
|
3
|
-
class KeyPlaysViewModel {
|
|
4
|
-
constructor() {
|
|
5
|
-
Object.defineProperty(this, "currentlyPlayingClipIndex", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
configurable: true,
|
|
8
|
-
writable: true,
|
|
9
|
-
value: new Observable(null)
|
|
10
|
-
});
|
|
11
|
-
Object.defineProperty(this, "lastPlayedClipIndex", {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
configurable: true,
|
|
14
|
-
writable: true,
|
|
15
|
-
value: new Observable(null)
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(this, "currentClipPlaybackProgress", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
configurable: true,
|
|
20
|
-
writable: true,
|
|
21
|
-
value: new Observable(null)
|
|
22
|
-
});
|
|
23
|
-
Object.defineProperty(this, "errorState", {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
configurable: true,
|
|
26
|
-
writable: true,
|
|
27
|
-
value: new Observable('unpopulatedEvent')
|
|
28
|
-
});
|
|
29
|
-
Object.defineProperty(this, "failedClips", {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
configurable: true,
|
|
32
|
-
writable: true,
|
|
33
|
-
value: new Observable({})
|
|
34
|
-
});
|
|
35
|
-
Object.defineProperty(this, "items", {
|
|
36
|
-
enumerable: true,
|
|
37
|
-
configurable: true,
|
|
38
|
-
writable: true,
|
|
39
|
-
value: new Observable([])
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
isCurrentlyPlaying(index) {
|
|
43
|
-
return index === this.currentlyPlayingClipIndex.value;
|
|
44
|
-
}
|
|
45
|
-
async setKeyPlays(items) {
|
|
46
|
-
if (items === null) {
|
|
47
|
-
this.errorState.value = 'tabLoadFailure';
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
this.items.value = this.parseNetworkResponse(items);
|
|
51
|
-
this.cleanErrors();
|
|
52
|
-
}
|
|
53
|
-
cleanErrors() {
|
|
54
|
-
if (this.errorState.value === 'tabLoadFailure') {
|
|
55
|
-
this.errorState.value = null;
|
|
56
|
-
}
|
|
57
|
-
if (this.errorState.value === 'unpopulatedEvent' && this.allItems.length) {
|
|
58
|
-
this.errorState.value = null;
|
|
59
|
-
}
|
|
60
|
-
if (!this.allItems.length) {
|
|
61
|
-
this.errorState.value = 'unpopulatedEvent';
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
async playKeyPlay(atIndex) {
|
|
65
|
-
const mevm = SDK.getMaestroEventViewModel();
|
|
66
|
-
mevm.delegate.playClip(atIndex);
|
|
67
|
-
}
|
|
68
|
-
parseNetworkResponse(response) {
|
|
69
|
-
const teams = Object.values(response.entities.team);
|
|
70
|
-
const athletes = Object.values(response.entities.athlete);
|
|
71
|
-
const homeTeam = teams.find((team) => team.homeAway === 'home');
|
|
72
|
-
const awayTeam = teams.find((team) => team.homeAway === 'away');
|
|
73
|
-
if (!homeTeam || !awayTeam) {
|
|
74
|
-
console.warn('Could not find home or away team');
|
|
75
|
-
return [];
|
|
76
|
-
}
|
|
77
|
-
const items = [];
|
|
78
|
-
const result = [];
|
|
79
|
-
for (const section of response.sections) {
|
|
80
|
-
for (const keyPlay of section.items) {
|
|
81
|
-
const playTeam = keyPlay.team
|
|
82
|
-
? teams.find((team) => team.id === keyPlay.team)
|
|
83
|
-
: undefined;
|
|
84
|
-
const athlete = keyPlay.athlete
|
|
85
|
-
? athletes.find((a) => a.id === keyPlay.athlete)
|
|
86
|
-
: undefined;
|
|
87
|
-
const teamImageUrl = playTeam ? playTeam.logoRef : undefined;
|
|
88
|
-
const playerImageUrl = athlete ? athlete.headshot : undefined;
|
|
89
|
-
const thumbnailImageUrl = keyPlay.thumbnailType !== 'headshot' ? keyPlay.thumbnail : undefined;
|
|
90
|
-
const homeScore = keyPlay.homeScore ? keyPlay.homeScore : '0';
|
|
91
|
-
const awayScore = keyPlay.awayScore ? keyPlay.awayScore : '0';
|
|
92
|
-
const homeTeamScore = keyPlay.scoringPlay
|
|
93
|
-
? parseInt(homeScore)
|
|
94
|
-
: undefined;
|
|
95
|
-
const awayTeamScore = keyPlay.scoringPlay
|
|
96
|
-
? parseInt(awayScore)
|
|
97
|
-
: undefined;
|
|
98
|
-
const randomId = Math.random().toString(36).substring(2, 15);
|
|
99
|
-
const keyPlayData = {
|
|
100
|
-
id: randomId,
|
|
101
|
-
description: keyPlay.description ? keyPlay.description : '',
|
|
102
|
-
homeTeamName: homeTeam ? homeTeam.shortName : '',
|
|
103
|
-
awayTeamName: awayTeam ? awayTeam.shortName : '',
|
|
104
|
-
homeTeamScore,
|
|
105
|
-
awayTeamScore,
|
|
106
|
-
clipID: keyPlay.clipID,
|
|
107
|
-
teamImageUrl,
|
|
108
|
-
playerImageUrl,
|
|
109
|
-
thumbnailImageUrl,
|
|
110
|
-
section: section.title,
|
|
111
|
-
};
|
|
112
|
-
items.push(keyPlayData);
|
|
113
|
-
}
|
|
114
|
-
// Only add the section if it has items
|
|
115
|
-
if (items.length) {
|
|
116
|
-
const sectionTitle = section.title;
|
|
117
|
-
const existingSection = result.find((item) => item.title === sectionTitle);
|
|
118
|
-
if (existingSection) {
|
|
119
|
-
existingSection.items.push(...items);
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
result.push({
|
|
123
|
-
title: sectionTitle,
|
|
124
|
-
items: [...items],
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
// Reset items for the next section
|
|
128
|
-
items.length = 0;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return result;
|
|
132
|
-
}
|
|
133
|
-
get allItems() {
|
|
134
|
-
return this.items.value.reduce((acc, section) => {
|
|
135
|
-
return acc.concat(section.items);
|
|
136
|
-
}, []);
|
|
137
|
-
}
|
|
138
|
-
clipID(forKeyPlayAtIndex) {
|
|
139
|
-
const item = this.allItems[forKeyPlayAtIndex];
|
|
140
|
-
if (!item) {
|
|
141
|
-
return undefined;
|
|
142
|
-
}
|
|
143
|
-
return this.allItems[forKeyPlayAtIndex].clipID;
|
|
144
|
-
}
|
|
145
|
-
handleKeyPlayLoadFailure(forKeyPlayAtIndex) {
|
|
146
|
-
const clipID = this.clipID(forKeyPlayAtIndex);
|
|
147
|
-
if (clipID) {
|
|
148
|
-
const newFailedClips = this.failedClips.value;
|
|
149
|
-
newFailedClips[clipID] = 'recentFailure';
|
|
150
|
-
this.failedClips.value = newFailedClips;
|
|
151
|
-
setTimeout(() => {
|
|
152
|
-
if (this.loadFailureStatus(forKeyPlayAtIndex) === 'recentFailure') {
|
|
153
|
-
const newFailedClips = this.failedClips.value;
|
|
154
|
-
newFailedClips[clipID] = 'nonRecentFailure';
|
|
155
|
-
this.failedClips.value = newFailedClips;
|
|
156
|
-
}
|
|
157
|
-
}, 5000);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
loadFailureStatus(forKeyPlayAtIndex) {
|
|
161
|
-
const clipID = this.clipID(forKeyPlayAtIndex);
|
|
162
|
-
const newFailedClips = this.failedClips.value;
|
|
163
|
-
if (!newFailedClips) {
|
|
164
|
-
return 'noFailure';
|
|
165
|
-
}
|
|
166
|
-
return clipID ? this.failedClips.value[clipID] : 'noFailure';
|
|
167
|
-
}
|
|
168
|
-
clearLoadFailureStatus(forKeyPlayAtIndex) {
|
|
169
|
-
const clipID = this.clipID(forKeyPlayAtIndex);
|
|
170
|
-
if (clipID && this.failedClips) {
|
|
171
|
-
this.failedClips.value = {
|
|
172
|
-
...this.failedClips.value,
|
|
173
|
-
[clipID]: 'noFailure',
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
async userRequestedNewKeyPlaysData() {
|
|
178
|
-
const mevm = SDK.getMaestroEventViewModel();
|
|
179
|
-
await mevm.delegate.userRequestedNewKeyPlaysData();
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
export default KeyPlaysViewModel;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|